aboutsummaryrefslogtreecommitdiffstats
path: root/web/nms.gathering.org/speedometer/d3-master/test/layout
diff options
context:
space:
mode:
authorKristian Lyngstol <kristian@bohemians.org>2015-04-02 19:24:45 +0200
committerKristian Lyngstol <kristian@bohemians.org>2015-04-02 19:24:45 +0200
commit0d8bba263dc195147d6fdb09662e7926f0a58b3e (patch)
tree4c570b4376c323e585120e7695b8715be7aa8881 /web/nms.gathering.org/speedometer/d3-master/test/layout
parente4354b47bd8891c5b1ee591fdf74b3ca67eee461 (diff)
Bump lots of changes
Diffstat (limited to 'web/nms.gathering.org/speedometer/d3-master/test/layout')
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/test/layout/chord-test.js164
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/test/layout/cluster-test.js44
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/test/layout/force-test.js119
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/test/layout/hierarchy-test.js40
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/test/layout/histogram-test.js92
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/test/layout/pack-test.js129
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/test/layout/partition-test.js45
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/test/layout/pie-test.js24
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/test/layout/tree-test.js59
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/test/layout/treemap-test.js181
10 files changed, 897 insertions, 0 deletions
diff --git a/web/nms.gathering.org/speedometer/d3-master/test/layout/chord-test.js b/web/nms.gathering.org/speedometer/d3-master/test/layout/chord-test.js
new file mode 100644
index 0000000..f2627bd
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/test/layout/chord-test.js
@@ -0,0 +1,164 @@
+var vows = require("vows"),
+ load = require("../load"),
+ assert = require("../assert");
+
+var suite = vows.describe("d3.layout.chord");
+
+suite.addBatch({
+ "chord": {
+ topic: load("layout/chord").expression("d3.layout.chord"),
+ "of a simple matrix": {
+ topic: function(chord) {
+ return chord()
+ .padding(.05)
+ .sortSubgroups(function(a, b) { return b - a; })
+ .matrix([
+ [11975, 5871, 8916, 2868],
+ [ 1951, 10048, 2060, 6171],
+ [ 8010, 16145, 8090, 8045],
+ [ 1013, 990, 940, 6907]
+ ]);
+ },
+ "computes chord groups": function(chord) {
+ var groups = chord.groups();
+ assert.equal(groups.length, 4);
+
+ assert.equal(groups[0].index, 0);
+ assert.inDelta(groups[0].startAngle, 0.0000000000000000, 1e-6);
+ assert.inDelta(groups[0].endAngle, 1.8024478065173115, 1e-6);
+ assert.inDelta(groups[0].value, 29630, 1e-6);
+
+ assert.equal(groups[1].index, 1);
+ assert.inDelta(groups[1].startAngle, 1.8524478065173116, 1e-6);
+ assert.inDelta(groups[1].endAngle, 3.0830761941597418, 1e-6);
+ assert.inDelta(groups[1].value, 20230, 1e-6);
+
+ assert.equal(groups[2].index, 2);
+ assert.inDelta(groups[2].startAngle, 3.1330761941597416, 1e-6);
+ assert.inDelta(groups[2].endAngle, 5.583991554422396, 1e-6);
+ assert.inDelta(groups[2].value, 40290, 1e-6);
+
+ assert.equal(groups[3].index, 3);
+ assert.inDelta(groups[3].startAngle, 5.6339915544223960, 1e-6);
+ assert.inDelta(groups[3].endAngle, 6.233185307179585, 1e-6);
+ assert.inDelta(groups[3].value, 9850, 1e-6);
+ },
+ "computes chords": function(chord) {
+ var chords = chord.chords();
+ assert.equal(chords.length, 10);
+
+ assert.equal(chords[0].source.index, 0);
+ assert.equal(chords[0].source.subindex, 0);
+ assert.inDelta(chords[0].source.startAngle, 0, 1e-6);
+ assert.inDelta(chords[0].source.endAngle, 0.7284614405347555, 1e-6);
+ assert.equal(chords[0].source.value, 11975);
+ assert.equal(chords[0].target.index, 0);
+ assert.equal(chords[0].target.subindex, 0);
+ assert.inDelta(chords[0].target.startAngle, 0, 1e-6);
+ assert.inDelta(chords[0].target.endAngle, 0.7284614405347555, 1e-6);
+ assert.equal(chords[0].target.value, 11975);
+
+ assert.equal(chords[1].source.index, 0);
+ assert.equal(chords[1].source.subindex, 1);
+ assert.inDelta(chords[1].source.startAngle, 1.2708382425228875, 1e-6);
+ assert.inDelta(chords[1].source.endAngle, 1.6279820519074009, 1e-6);
+ assert.equal(chords[1].source.value, 5871);
+ assert.equal(chords[1].target.index, 1);
+ assert.equal(chords[1].target.subindex, 0);
+ assert.inDelta(chords[1].target.startAngle, 2.964393248816668, 1e-6);
+ assert.inDelta(chords[1].target.endAngle, 3.0830761941597418, 1e-6);
+ assert.equal(chords[1].target.value, 1951);
+
+ assert.equal(chords[2].source.index, 0);
+ assert.equal(chords[2].source.subindex, 2);
+ assert.inDelta(chords[2].source.startAngle, 0.7284614405347555, 1e-6);
+ assert.inDelta(chords[2].source.endAngle, 1.2708382425228875, 1e-6);
+ assert.equal(chords[2].source.value, 8916);
+ assert.equal(chords[2].target.index, 2);
+ assert.equal(chords[2].target.subindex, 0);
+ assert.inDelta(chords[2].target.startAngle, 5.0967284113173115, 1e-6);
+ assert.inDelta(chords[2].target.endAngle, 5.583991554422396, 1e-6);
+ assert.equal(chords[2].target.value, 8010);
+
+ assert.equal(chords[3].source.index, 0);
+ assert.equal(chords[3].source.subindex, 3);
+ assert.inDelta(chords[3].source.startAngle, 1.6279820519074009, 1e-6);
+ assert.inDelta(chords[3].source.endAngle, 1.8024478065173115, 1e-6);
+ assert.equal(chords[3].source.value, 2868);
+ assert.equal(chords[3].target.index, 3);
+ assert.equal(chords[3].target.subindex, 0);
+ assert.inDelta(chords[3].target.startAngle, 6.05415716358929, 1e-6);
+ assert.inDelta(chords[3].target.endAngle, 6.115779830751019, 1e-6);
+ assert.equal(chords[3].target.value, 1013);
+
+ assert.equal(chords[4].source.index, 1);
+ assert.equal(chords[4].source.subindex, 1);
+ assert.inDelta(chords[4].source.startAngle, 1.8524478065173116, 1e-6);
+ assert.inDelta(chords[4].source.endAngle, 2.4636862661827164, 1e-6);
+ assert.equal(chords[4].source.value, 10048);
+ assert.equal(chords[4].target.index, 1);
+ assert.equal(chords[4].target.subindex, 1);
+ assert.inDelta(chords[4].target.startAngle, 1.8524478065173116, 1e-6);
+ assert.inDelta(chords[4].target.endAngle, 2.4636862661827164, 1e-6);
+ assert.equal(chords[4].target.value, 10048);
+
+ assert.equal(chords[5].source.index, 2);
+ assert.equal(chords[5].source.subindex, 1);
+ assert.inDelta(chords[5].source.startAngle, 3.1330761941597416, 1e-6);
+ assert.inDelta(chords[5].source.endAngle, 4.1152064620038855, 1e-6);
+ assert.equal(chords[5].source.value, 16145);
+ assert.equal(chords[5].target.index, 1);
+ assert.equal(chords[5].target.subindex, 2);
+ assert.inDelta(chords[5].target.startAngle, 2.8390796314887687, 1e-6);
+ assert.inDelta(chords[5].target.endAngle, 2.964393248816668, 1e-6);
+ assert.equal(chords[5].target.value, 2060);
+
+ assert.equal(chords[6].source.index, 1);
+ assert.equal(chords[6].source.subindex, 3);
+ assert.inDelta(chords[6].source.startAngle, 2.4636862661827164, 1e-6);
+ assert.inDelta(chords[6].source.endAngle, 2.8390796314887687, 1e-6);
+ assert.equal(chords[6].source.value, 6171);
+ assert.equal(chords[6].target.index, 3);
+ assert.equal(chords[6].target.subindex, 1);
+ assert.inDelta(chords[6].target.startAngle, 6.115779830751019, 1e-6);
+ assert.inDelta(chords[6].target.endAngle, 6.176003365292097, 1e-6);
+ assert.equal(chords[6].target.value, 990);
+
+ assert.equal(chords[7].source.index, 2);
+ assert.equal(chords[7].source.subindex, 2);
+ assert.inDelta(chords[7].source.startAngle, 4.1152064620038855, 1e-6);
+ assert.inDelta(chords[7].source.endAngle, 4.607336153354714, 1e-6);
+ assert.equal(chords[7].source.value, 8090);
+ assert.equal(chords[7].target.index, 2);
+ assert.equal(chords[7].target.subindex, 2);
+ assert.inDelta(chords[7].target.startAngle, 4.1152064620038855, 1e-6);
+ assert.inDelta(chords[7].target.endAngle, 4.607336153354714, 1e-6);
+ assert.equal(chords[7].target.value, 8090);
+
+ assert.equal(chords[8].source.index, 2);
+ assert.equal(chords[8].source.subindex, 3);
+ assert.inDelta(chords[8].source.startAngle, 4.607336153354714, 1e-6);
+ assert.inDelta(chords[8].source.endAngle, 5.0967284113173115, 1e-6);
+ assert.equal(chords[8].source.value, 8045);
+ assert.equal(chords[8].target.index, 3);
+ assert.equal(chords[8].target.subindex, 2);
+ assert.inDelta(chords[8].target.startAngle, 6.176003365292097, 1e-6);
+ assert.inDelta(chords[8].target.endAngle, 6.233185307179585, 1e-6);
+ assert.equal(chords[8].target.value, 940);
+
+ assert.equal(chords[9].source.index, 3);
+ assert.equal(chords[9].source.subindex, 3);
+ assert.inDelta(chords[9].source.startAngle, 5.633991554422396, 1e-6);
+ assert.inDelta(chords[9].source.endAngle, 6.05415716358929, 1e-6);
+ assert.equal(chords[9].source.value, 6907);
+ assert.equal(chords[9].target.index, 3);
+ assert.equal(chords[9].target.subindex, 3);
+ assert.inDelta(chords[9].target.startAngle, 5.633991554422396, 1e-6);
+ assert.inDelta(chords[9].target.endAngle, 6.05415716358929, 1e-6);
+ assert.equal(chords[9].target.value, 6907);
+ }
+ }
+ }
+});
+
+suite.export(module);
diff --git a/web/nms.gathering.org/speedometer/d3-master/test/layout/cluster-test.js b/web/nms.gathering.org/speedometer/d3-master/test/layout/cluster-test.js
new file mode 100644
index 0000000..caa2747
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/test/layout/cluster-test.js
@@ -0,0 +1,44 @@
+var vows = require("vows"),
+ load = require("../load"),
+ assert = require("../assert");
+
+var suite = vows.describe("d3.layout.cluster");
+
+suite.addBatch({
+ "cluster": {
+ topic: load("layout/cluster").expression("d3.layout.cluster"),
+ "can handle an empty children array": function(cluster) {
+ var c = cluster();
+ assert.deepEqual(c.nodes({value: 1, children: [{value: 1, children: []}, {value: 1}]}).map(layout), [
+ {value: 1, depth: 0, x: 0.5, y: 0},
+ {value: 1, depth: 1, x: 0.25, y: 1},
+ {value: 1, depth: 1, x: 0.75, y: 1}
+ ]);
+ },
+ "can handle zero-valued nodes": function(cluster) {
+ var c = cluster();
+ assert.deepEqual(c.nodes({value: 0, children: [{value: 0}, {value: 1}]}).map(layout), [
+ {value: 0, depth: 0, x: 0.5, y: 0},
+ {value: 0, depth: 1, x: 0.25, y: 1},
+ {value: 1, depth: 1, x: 0.75, y: 1}
+ ]);
+ },
+ "can handle a single node": function(cluster) {
+ var c = cluster();
+ assert.deepEqual(c.nodes({value: 0}).map(layout), [
+ {value: 0, depth: 0, x: 0.5, y: 0}
+ ]);
+ }
+ }
+});
+
+function layout(node) {
+ return {
+ value: node.value,
+ depth: node.depth,
+ x: node.x,
+ y: node.y
+ };
+}
+
+suite.export(module);
diff --git a/web/nms.gathering.org/speedometer/d3-master/test/layout/force-test.js b/web/nms.gathering.org/speedometer/d3-master/test/layout/force-test.js
new file mode 100644
index 0000000..a4b5870
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/test/layout/force-test.js
@@ -0,0 +1,119 @@
+var vows = require("vows"),
+ load = require("../load"),
+ assert = require("../assert");
+
+var suite = vows.describe("d3.layout.force");
+
+suite.addBatch({
+ "force": {
+ topic: load("layout/force").expression("d3.layout.force").document(),
+
+ "default instance": {
+ topic: function(force) {
+ return force();
+ },
+
+ "friction": {
+ "defaults to .9": function(f) {
+ assert.equal(f.friction(), .9);
+ },
+ "can be a number": function(f) {
+ f.friction(.5);
+ assert.equal(f.friction(), .5);
+ },
+ "coerces to a number": function(f) {
+ f.friction(".5");
+ assert.strictEqual(f.friction(), .5);
+ }
+ },
+
+ "gravity": {
+ "defaults to .1": function(f) {
+ assert.equal(f.gravity(), .1);
+ },
+ "can be a number": function(f) {
+ f.gravity(.5);
+ assert.equal(f.gravity(), .5);
+ },
+ "coerces to a number": function(f) {
+ f.gravity(".5");
+ assert.strictEqual(f.gravity(), .5);
+ }
+ },
+
+ "theta": {
+ "defaults to .8": function(f) {
+ assert.equal(f.theta(), .8);
+ },
+ "can be a number": function(f) {
+ f.theta(.5);
+ assert.equal(f.theta(), .5);
+ },
+ "coerces to a number": function(f) {
+ f.theta(".5");
+ assert.strictEqual(f.theta(), .5);
+ }
+ },
+
+ "charge": {
+ "defaults to -30": function(f) {
+ assert.equal(f.charge(), -30);
+ },
+ "can be a number": function(f) {
+ f.charge(-40);
+ assert.equal(f.charge(), -40);
+ },
+ "can be a function": function(f) { // TODO expose the computed value?
+ f.charge(foo);
+ assert.equal(f.charge(), foo);
+ },
+ "coerces to a number": function(f) {
+ f.charge("-40");
+ assert.strictEqual(f.charge(), -40);
+ }
+ },
+
+ "linkDistance": {
+ "defaults to 20": function(f) {
+ assert.equal(f.linkDistance(), 20);
+ },
+ "can be a number": function(f) {
+ f.linkDistance(40);
+ assert.equal(f.linkDistance(), 40);
+ },
+ "can be a function": function(f) { // TODO expose the computed value?
+ f.linkDistance(foo);
+ assert.equal(f.linkDistance(), foo);
+ },
+ "coerces to a number": function(f) {
+ f.linkDistance("40");
+ assert.strictEqual(f.linkDistance(), 40);
+ }
+ },
+
+ "linkStrength": {
+ "defaults to 1": function(f) {
+ assert.equal(f.linkStrength(), 1);
+ },
+ "can be a number": function(f) {
+ f.linkStrength(.5);
+ assert.equal(f.linkStrength(), .5);
+ },
+ "can be a function": function(f) { // TODO expose the computed value?
+ f.linkStrength(foo);
+ assert.equal(f.linkStrength(), foo);
+ },
+ "coerces to a number": function(f) {
+ f.linkStrength(".5");
+ assert.strictEqual(f.linkStrength(), .5);
+ }
+ }
+ }
+ }
+});
+
+function foo(d) {
+ return d.foo;
+}
+
+suite.export(module);
diff --git a/web/nms.gathering.org/speedometer/d3-master/test/layout/hierarchy-test.js b/web/nms.gathering.org/speedometer/d3-master/test/layout/hierarchy-test.js
new file mode 100644
index 0000000..274dcaa
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/test/layout/hierarchy-test.js
@@ -0,0 +1,40 @@
+var vows = require("vows"),
+ load = require("../load"),
+ assert = require("../assert");
+
+var suite = vows.describe("d3.layout.hierarchy");
+
+suite.addBatch({
+ "hierarchy": {
+ topic: load("layout/treemap").expression("d3.layout.treemap"), // hierarchy is abstract, so test a subclass
+ "doesn't overwrite the value of a node that has an empty children array": function(hierarchy) {
+ var h = hierarchy(),
+ nodes = h.sticky(true).nodes({value: 1, children: []});
+ assert.equal(nodes[0].value, 1);
+ h.nodes(nodes[0]);
+ assert.equal(nodes[0].value, 1);
+ },
+ "a valueless node that has an empty children array gets a value of 0": function(hierarchy) {
+ var h = hierarchy(),
+ nodes = h.sticky(true).nodes({children: []});
+ assert.equal(nodes[0].value, 0);
+ h.nodes(nodes[0]);
+ assert.equal(nodes[0].value, 0);
+ },
+ "removes the children array for a node that has no children": function(hierarchy) {
+ var h = hierarchy(),
+ nodes = h.children(function() { return null; }).nodes({children: [{}]});
+ assert.equal(nodes[0].value, 0);
+ assert.isUndefined(nodes[0].children);
+ },
+ "revalue": function(hierarchy) {
+ var h = hierarchy().sticky(true),
+ nodes = h.nodes({children: [{children: [{value: 1}, {value: 2}]}, {value: 3}]});
+ assert.equal(nodes[0].value, 6);
+ h(nodes[0]); // calls hierarchy.revalue
+ assert.equal(nodes[0].value, 6);
+ }
+ }
+});
+
+suite.export(module);
diff --git a/web/nms.gathering.org/speedometer/d3-master/test/layout/histogram-test.js b/web/nms.gathering.org/speedometer/d3-master/test/layout/histogram-test.js
new file mode 100644
index 0000000..004bcdc
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/test/layout/histogram-test.js
@@ -0,0 +1,92 @@
+var vows = require("vows"),
+ load = require("../load"),
+ assert = require("../assert");
+
+var suite = vows.describe("d3.layout.histogram");
+
+suite.addBatch({
+ "histogram": {
+ topic: load("layout/histogram").expression("d3.layout.histogram"),
+ "defaults to frequencies": function(histogram) {
+ var h = histogram();
+ assert.deepEqual(h([0,0,0,1,2,2]).map(elements), [[0, 0, 0], [], [1], [2, 2]]);
+ },
+ "each bin contains the matching source elements": function(histogram) {
+ var h = histogram();
+ assert.deepEqual(h([0,0,0,1,2,2]).map(elements), [[0, 0, 0], [], [1], [2, 2]]);
+ },
+ "each bin also has defined x, y and dx properties": function(histogram) {
+ var h = histogram();
+ assert.deepEqual(h([0,0,0,1,2,2]).map(metadata), [
+ {x: 0, y: 3, dx: 0.5},
+ {x: 0.5, y: 0, dx: 0.5},
+ {x: 1, y: 1, dx: 0.5},
+ {x: 1.5, y: 2, dx: 0.5}
+ ]);
+ },
+ "can output frequencies": function(histogram) {
+ var h = histogram().frequency(true);
+ assert.deepEqual(h([0,0,0,1,2,2]).map(metadata), [
+ {x: 0, y: 3, dx: 0.5},
+ {x: 0.5, y: 0, dx: 0.5},
+ {x: 1, y: 1, dx: 0.5},
+ {x: 1.5, y: 2, dx: 0.5}
+ ]);
+ },
+ "can output probabilities": function(histogram) {
+ var h = histogram().frequency(false);
+ assert.deepEqual(h([0,0,0,1,2,2]).map(metadata), [
+ {x: 0, y: 3/6, dx: 0.5},
+ {x: 0.5, y: 0, dx: 0.5},
+ {x: 1, y: 1/6, dx: 0.5},
+ {x: 1.5, y: 2/6, dx: 0.5}
+ ]);
+ },
+ "can specify number of bins": function(histogram) {
+ var h = histogram().bins(2);
+ assert.deepEqual(h([0,0,0,1,2,2]).map(elements), [
+ [0, 0, 0],
+ [1, 2, 2]
+ ]);
+ assert.deepEqual(h([0,0,0,1,2,2]).map(metadata), [
+ {x: 0, y: 3, dx: 1},
+ {x: 1, y: 3, dx: 1}
+ ]);
+ },
+ "can specify bin thresholds": function(histogram) {
+ var h = histogram().bins([0,1,2,3]);
+ assert.deepEqual(h([0,0,0,1,2,2]).map(elements), [
+ [0, 0, 0],
+ [1],
+ [2, 2]
+ ]);
+ assert.deepEqual(h([0,0,0,1,2,2]).map(metadata), [
+ {x: 0, y: 3, dx: 1},
+ {x: 1, y: 1, dx: 1},
+ {x: 2, y: 2, dx: 1}
+ ]);
+ },
+ "returns the empty array with fewer than two bins": function(histogram) {
+ var h = histogram().bins([1]);
+ assert.deepEqual(h([0]), []);
+ var h = histogram().bins([]);
+ assert.deepEqual(h([0]), []);
+ }
+ }
+});
+
+function elements(bin) {
+ var array = [], i = -1, n = bin.length;
+ while (++i < n) array.push(bin[i]);
+ return array;
+}
+
+function metadata(bin) {
+ var metadata = {};
+ if ("x" in bin) metadata.x = bin.x;
+ if ("y" in bin) metadata.y = bin.y;
+ if ("dx" in bin) metadata.dx = bin.dx;
+ return metadata;
+}
+
+suite.export(module);
diff --git a/web/nms.gathering.org/speedometer/d3-master/test/layout/pack-test.js b/web/nms.gathering.org/speedometer/d3-master/test/layout/pack-test.js
new file mode 100644
index 0000000..5c39ea5
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/test/layout/pack-test.js
@@ -0,0 +1,129 @@
+var vows = require("vows"),
+ load = require("../load"),
+ assert = require("../assert");
+
+var suite = vows.describe("d3.layout.pack");
+
+suite.addBatch({
+ "pack": {
+ topic: load("layout/pack").expression("d3.layout.pack"),
+ "can handle an empty children array": function(pack) {
+ var p = pack();
+ assert.deepEqual(p.nodes({children: [{children: []}, {value: 1}]}).map(layout), [
+ {value: 1, depth: 0, x: 0.5, y: 0.5, r: 0.5},
+ {value: 0, depth: 1, x: 0.0, y: 0.5, r: 0.0},
+ {value: 1, depth: 1, x: 0.5, y: 0.5, r: 0.5}
+ ]);
+ },
+ "can handle zero-valued nodes": function(pack) {
+ var p = pack();
+ assert.deepEqual(p.nodes({children: [{value: 0}, {value: 1}]}).map(layout), [
+ {value: 1, depth: 0, x: 0.5, y: 0.5, r: 0.5},
+ {value: 0, depth: 1, x: 0.0, y: 0.5, r: 0.0},
+ {value: 1, depth: 1, x: 0.5, y: 0.5, r: 0.5}
+ ]);
+ },
+ "can handle small nodes": function(pack) {
+ assert.deepEqual(pack().sort(null).nodes({children: [
+ {value: .01},
+ {value: 2},
+ {value: 2},
+ {value: 1}
+ ]}).map(layout), [
+ {y: 0.5, x: 0.5, value: 5.01, r: 0.5, depth: 0},
+ {y: 0.5084543199854831, x: 0.4682608366855136, value: 0.01, r: 0.016411496513964046, depth: 1},
+ {y: 0.5084543199854831, x: 0.7167659426883449, value: 2, r: 0.23209360948886723, depth: 1},
+ {y: 0.34256315498862167, x: 0.2832340573116551, value: 2, r: 0.23209360948886723, depth: 1},
+ {y: 0.7254154893606051, x: 0.38524055061025186, value: 1, r: 0.16411496513964044, depth: 1}
+ ]);
+ assert.deepEqual(pack().sort(null).nodes({children: [
+ {value: 2},
+ {value: 2},
+ {value: 1},
+ {value: .01}
+ ]}).map(layout), [
+ {y: 0.5, x: 0.5, value: 5.01, r: 0.5, depth: 0},
+ {y: 0.6274712284943809, x: 0.26624891409386664, value: 2, r: 0.23375108590613333, depth: 1},
+ {y: 0.6274712284943809, x: 0.7337510859061334, value: 2, r: 0.23375108590613333, depth: 1},
+ {y: 0.30406466355343187, x: 0.5, value: 1, r: 0.1652869779539461, depth: 1},
+ {y: 0.3878967195987758, x: 0.3386645534068854, value: 0.01, r: 0.01652869779539461, depth: 1}
+ ]);
+ },
+ "can handle residual floating point error": function(pack) {
+ var p = pack();
+ var result = p.nodes({children: [
+ {value: 0.005348322447389364},
+ {value: 0.8065882022492588},
+ {value: 0}
+ ]}).map(layout);
+ assert.isFalse(result.map(function(d) { return d.depth; }).some(isNaN));
+ assert.isFalse(result.map(function(d) { return d.value; }).some(isNaN));
+ assert.isFalse(result.map(function(d) { return d.x; }).some(isNaN));
+ assert.isFalse(result.map(function(d) { return d.y; }).some(isNaN));
+ assert.isFalse(result.map(function(d) { return d.r; }).some(isNaN));
+ },
+ "avoids coincident circles": function(pack) {
+ var p = pack();
+ var result = p({children: [
+ {children: [{value: 17010}, {value: 5842}, {value: 0}, {value: 0}]},
+ {children: [
+ {children: [{value: 721}, {value: 4294}, {value: 9800}, {value: 1314}, {value: 2220}]},
+ {value: 1759}, {value: 2165}, {value: 586}, {value: 3331}, {value: 772}, {value: 3322}
+ ]}
+ ]}).map(layout);
+ result.sort(function(a, b) {
+ return a.x < b.x && a.y < b.y ? -1 : 1;
+ });
+ assert.isFalse(result.slice(1).some(function(d, i) {
+ return d.x === result[i].x && d.y === result[i].y && d.value > 0;
+ }));
+ },
+ "radius defaults to automatic scaling": function(pack) {
+ assert.equal(pack().radius(), null);
+ },
+ "radius can be specified using a custom function of value": function(pack) {
+ var r = function(value) { return Math.sqrt(value) * 10; },
+ p = pack().radius(r);
+ assert.strictEqual(p.radius(), r);
+ assert.deepEqual(p.nodes({children: [{value: 1}]}).map(layout), [
+ {value: 1, depth: 0, x: 0.5, y: 0.5, r: 10},
+ {value: 1, depth: 1, x: 0.5, y: 0.5, r: 10}
+ ]);
+ },
+ "radius can be specified as a constant": function(pack) {
+ var p = pack().radius(5);
+ assert.equal(p.radius(), 5);
+ assert.deepEqual(p.nodes({children: [{value: 1}]}).map(layout), [
+ {value: 1, depth: 0, x: 0.5, y: 0.5, r: 5},
+ {value: 1, depth: 1, x: 0.5, y: 0.5, r: 5}
+ ]);
+ },
+ "radius constant value is coerced to a number": function(pack) {
+ var p = pack().radius("5");
+ assert.equal(p.radius(), 5);
+ assert.deepEqual(p.nodes({children: [{value: 1}]}).map(layout), [
+ {value: 1, depth: 0, x: 0.5, y: 0.5, r: 5},
+ {value: 1, depth: 1, x: 0.5, y: 0.5, r: 5}
+ ]);
+ },
+ "radius function value is coerced to a number": function(pack) {
+ var p = pack().radius(function() { return "5"; });
+ assert.deepEqual(p.nodes({children: [{value: 1}]}).map(layout), [
+ {value: 1, depth: 0, x: 0.5, y: 0.5, r: 5},
+ {value: 1, depth: 1, x: 0.5, y: 0.5, r: 5}
+ ]);
+ }
+ }
+});
+
+function layout(node) {
+ return {
+ value: node.value,
+ depth: node.depth,
+ r: node.r,
+ x: node.x,
+ y: node.y
+ };
+}
+
+suite.export(module);
diff --git a/web/nms.gathering.org/speedometer/d3-master/test/layout/partition-test.js b/web/nms.gathering.org/speedometer/d3-master/test/layout/partition-test.js
new file mode 100644
index 0000000..e7aba25
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/test/layout/partition-test.js
@@ -0,0 +1,45 @@
+var vows = require("vows"),
+ load = require("../load"),
+ assert = require("../assert");
+
+var suite = vows.describe("d3.layout.partition");
+
+suite.addBatch({
+ "partition": {
+ topic: load("layout/partition").expression("d3.layout.partition"),
+ "ignores zero values": function(partition) {
+ var p = partition().size([3, 3]);
+ assert.deepEqual(p.nodes({children: [{value: 1}, {value: 0}, {value: 2}, {children: [{value: 0}, {value: 0}]}]}).map(metadata), [
+ {x: 0, y: 0, dx: 3, dy: 1},
+ {x: 2, y: 1, dx: 1, dy: 1},
+ {x: 3, y: 1, dx: 0, dy: 1},
+ {x: 0, y: 1, dx: 2, dy: 1},
+ {x: 3, y: 1, dx: 0, dy: 1},
+ {x: 3, y: 2, dx: 0, dy: 1},
+ {x: 3, y: 2, dx: 0, dy: 1}
+ ]);
+ },
+ "can handle an empty children array": function(partition) {
+ var p = partition();
+ assert.deepEqual(p.nodes({children: []}).map(metadata), [
+ {x: 0, y: 0, dx: 1, dy: 1}
+ ]);
+ assert.deepEqual(p.nodes({children: [{children: []}, {value: 1}]}).map(metadata), [
+ {x: 0, y: 0, dx: 1, dy: 0.5},
+ {x: 1, y: 0.5, dx: 0, dy: 0.5},
+ {x: 0, y: 0.5, dx: 1, dy: 0.5}
+ ]);
+ }
+ }
+});
+
+function metadata(node) {
+ var metadata = {};
+ if ("x" in node) metadata.x = node.x;
+ if ("y" in node) metadata.y = node.y;
+ if ("dx" in node) metadata.dx = node.dx;
+ if ("dy" in node) metadata.dy = node.dy;
+ return metadata;
+}
+
+suite.export(module);
diff --git a/web/nms.gathering.org/speedometer/d3-master/test/layout/pie-test.js b/web/nms.gathering.org/speedometer/d3-master/test/layout/pie-test.js
new file mode 100644
index 0000000..f4fb2f1
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/test/layout/pie-test.js
@@ -0,0 +1,24 @@
+var vows = require("vows"),
+ load = require("../load"),
+ assert = require("../assert");
+
+var suite = vows.describe("d3.layout.pie");
+
+suite.addBatch({
+ "pie": {
+ topic: load("layout/pie").expression("d3.layout.pie"),
+ "arcs are in same order as original data": function(pie) {
+ var p = pie();
+ assert.deepEqual(p([5, 30, 15]).map(function(d) { return d.data; }), [
+ 5, 30, 15
+ ]);
+ assert.deepEqual(p([
+ 84, 90, 48, 61, 58, 8, 6, 31, 45, 18
+ ]).map(function(d) { return d.data; }), [
+ 84, 90, 48, 61, 58, 8, 6, 31, 45, 18
+ ]);
+ }
+ }
+});
+
+suite.export(module);
diff --git a/web/nms.gathering.org/speedometer/d3-master/test/layout/tree-test.js b/web/nms.gathering.org/speedometer/d3-master/test/layout/tree-test.js
new file mode 100644
index 0000000..a691788
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/test/layout/tree-test.js
@@ -0,0 +1,59 @@
+var vows = require("vows"),
+ load = require("../load"),
+ assert = require("../assert");
+
+var suite = vows.describe("d3.layout.tree");
+
+suite.addBatch({
+ "tree": {
+ topic: load("layout/tree").expression("d3.layout.tree"),
+ "computes a simple tree layout": function(tree) {
+ var t = tree();
+ assert.deepEqual(t.nodes({
+ name: "1",
+ children: [
+ {name: "1-1"},
+ {name: "1-2"},
+ {name: "1-3"}
+ ]
+ }).map(layout), [
+ {name: "1", depth: 0, x: 0.5, y: 0},
+ {name: "1-1", depth: 1, x: 0.16666666666666666, y: 1},
+ {name: "1-2", depth: 1, x: 0.5, y: 1},
+ {name: "1-3", depth: 1, x: 0.8333333333333333, y: 1}
+ ]);
+ },
+ "can handle an empty children array": function(tree) {
+ var t = tree();
+ assert.deepEqual(t.nodes({children: []}).map(layout), [
+ {depth: 0, x: 0.5, y: 0}
+ ]);
+ assert.deepEqual(t.nodes({children: [
+ {children: []},
+ {children: [{}]},
+ {children: [{}]}
+ ]}).map(layout), [
+ {depth: 0, x: .5, y: 0},
+ {depth: 1, x: .125, y: 0.5},
+ {depth: 1, x: .375, y: 0.5},
+ {depth: 2, x: .375, y: 1},
+ {depth: 1, x: .875, y: 0.5},
+ {depth: 2, x: .875, y: 1}
+ ]);
+ },
+ "can handle a single node": function(tree) {
+ var t = tree();
+ assert.deepEqual(t.nodes({}).map(layout), [
+ {depth: 0, x: 0.5, y: 0}
+ ]);
+ }
+ }
+});
+
+function layout(node) {
+ delete node.children;
+ delete node.parent;
+ return node;
+}
+
+suite.export(module);
diff --git a/web/nms.gathering.org/speedometer/d3-master/test/layout/treemap-test.js b/web/nms.gathering.org/speedometer/d3-master/test/layout/treemap-test.js
new file mode 100644
index 0000000..a25b37f
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/test/layout/treemap-test.js
@@ -0,0 +1,181 @@
+var vows = require("vows"),
+ load = require("../load"),
+ assert = require("../assert");
+
+var suite = vows.describe("d3.layout.treemap");
+
+suite.addBatch({
+ "treemap": {
+ topic: load("layout/treemap").expression("d3.layout.treemap"),
+ "outputs a squarified treemap": function(treemap) {
+ var t = treemap().size([1000, 1000]).sort(null);
+ assert.deepEqual(t.nodes({children: [{value: 1}, {value: 2}, {children: [{value: 1}, {value: 2}]}]}).map(layout), [
+ {x: 0, y: 0, dx: 1000, dy: 1000},
+ {x: 0, y: 833, dx: 1000, dy: 167},
+ {x: 600, y: 0, dx: 400, dy: 833},
+ {x: 0, y: 0, dx: 600, dy: 833},
+ {x: 0, y: 555, dx: 600, dy: 278},
+ {x: 0, y: 0, dx: 600, dy: 555}
+ ]);
+ },
+ "sorts by value by default": function(treemap) {
+ var t = treemap().size([1000, 1000]);
+ assert.deepEqual(t.nodes({children: [{value: 1}, {value: 2}, {children: [{value: 1}, {value: 2}]}]}).map(layout), [
+ {x: 0, y: 0, dx: 1000, dy: 1000},
+ {x: 0, y: 0, dx: 333, dy: 500},
+ {x: 333, y: 0, dx: 667, dy: 500},
+ {x: 0, y: 500, dx: 1000, dy: 500},
+ {x: 0, y: 500, dx: 333, dy: 500},
+ {x: 333, y: 500, dx: 667, dy: 500}
+ ]);
+ },
+ "ignores zero values": function(treemap) {
+ var t = treemap().size([1000, 1000]).sort(null);
+ assert.deepEqual(t.nodes({children: [{value: 1}, {value: 0}, {value: 2}, {children: [{value: 1}, {value: 2}]}]}).map(layout), [
+ {x: 0, y: 0, dx: 1000, dy: 1000},
+ {x: 0, y: 833, dx: 1000, dy: 167},
+ {x: 1000, y: 0, dx: 0, dy: 833},
+ {x: 600, y: 0, dx: 400, dy: 833},
+ {x: 0, y: 0, dx: 600, dy: 833},
+ {x: 0, y: 555, dx: 600, dy: 278},
+ {x: 0, y: 0, dx: 600, dy: 555}
+ ]);
+ },
+ "ignores NaN values": function(treemap) {
+ var t = treemap().size([1000, 1000]).sort(null);
+ assert.deepEqual(t.nodes({children: [{value: 1}, {value: NaN}, {value: 2}, {children: [{value: 1}, {value: 2}]}]}).map(layout), [
+ {x: 0, y: 0, dx: 1000, dy: 1000},
+ {x: 0, y: 833, dx: 1000, dy: 167},
+ {x: 1000, y: 0, dx: 0, dy: 833},
+ {x: 600, y: 0, dx: 400, dy: 833},
+ {x: 0, y: 0, dx: 600, dy: 833},
+ {x: 0, y: 555, dx: 600, dy: 278},
+ {x: 0, y: 0, dx: 600, dy: 555}
+ ]);
+ },
+ "does not overflow empty size": function(treemap) {
+ var t = treemap().size([0, 0]).sort(null);
+ assert.deepEqual(t.nodes({children: [{value: 1}, {value: 2}, {children: [{value: 1}, {value: 2}]}]}).map(layout), [
+ {x: 0, y: 0, dx: 0, dy: 0},
+ {x: 0, y: 0, dx: 0, dy: 0},
+ {x: 0, y: 0, dx: 0, dy: 0},
+ {x: 0, y: 0, dx: 0, dy: 0},
+ {x: 0, y: 0, dx: 0, dy: 0},
+ {x: 0, y: 0, dx: 0, dy: 0}
+ ]);
+ },
+ "can specify padding as a number": function(treemap) {
+ var t = treemap().size([1000, 1000]).sort(null).padding(1);
+ assert.deepEqual(t.nodes({children: [{value: 1}, {value: 2}, {children: [{value: 1}, {value: 2}]}]}).map(layout), [
+ {x: 0, y: 0, dx: 1000, dy: 1000},
+ {x: 1, y: 833, dx: 998, dy: 166},
+ {x: 600, y: 1, dx: 399, dy: 832},
+ {x: 1, y: 1, dx: 599, dy: 832},
+ {x: 2, y: 555, dx: 597, dy: 277},
+ {x: 2, y: 2, dx: 597, dy: 553}
+ ]);
+ },
+ "can specify padding as an array": function(treemap) {
+ var t = treemap().size([1000, 1000]).sort(null).padding([1,2,3,4]);
+ assert.deepEqual(t.nodes({children: [{value: 1}, {value: 2}, {children: [{value: 1}, {value: 2}]}]}).map(layout), [
+ {x: 0, y: 0, dx: 1000, dy: 1000},
+ {x: 4, y: 831, dx: 994, dy: 166},
+ {x: 600, y: 1, dx: 398, dy: 830},
+ {x: 4, y: 1, dx: 596, dy: 830},
+ {x: 8, y: 553, dx: 590, dy: 275},
+ {x: 8, y: 2, dx: 590, dy: 551}
+ ]);
+ },
+ "can specify padding as null": function(treemap) {
+ var t = treemap().size([1000, 1000]).sort(null).padding(null);
+ assert.deepEqual(t.nodes({children: [{value: 1}, {value: 2}, {children: [{value: 1}, {value: 2}]}]}).map(layout), [
+ {x: 0, y: 0, dx: 1000, dy: 1000},
+ {x: 0, y: 833, dx: 1000, dy: 167},
+ {x: 600, y: 0, dx: 400, dy: 833},
+ {x: 0, y: 0, dx: 600, dy: 833},
+ {x: 0, y: 555, dx: 600, dy: 278},
+ {x: 0, y: 0, dx: 600, dy: 555}
+ ]);
+ },
+ "can specify padding as a function that returns a number": function(treemap) {
+ var t = treemap().size([1000, 1000]).sort(null).padding(function(d) { return d.depth; });
+ assert.deepEqual(t.nodes({children: [{value: 1}, {value: 2}, {children: [{value: 1}, {value: 2}]}]}).map(layout), [
+ {x: 0, y: 0, dx: 1000, dy: 1000},
+ {x: 0, y: 833, dx: 1000, dy: 167},
+ {x: 600, y: 0, dx: 400, dy: 833},
+ {x: 0, y: 0, dx: 600, dy: 833},
+ {x: 1, y: 555, dx: 598, dy: 277},
+ {x: 1, y: 1, dx: 598, dy: 554}
+ ]);
+ },
+ "can specify padding as a function that returns an array": function(treemap) {
+ var t = treemap().size([1000, 1000]).sort(null).padding(function(d) { return [d.depth,2,3,4]; });
+ assert.deepEqual(t.nodes({children: [{value: 1}, {value: 2}, {children: [{value: 1}, {value: 2}]}]}).map(layout), [
+ {x: 0, y: 0, dx: 1000, dy: 1000},
+ {x: 4, y: 831, dx: 994, dy: 166},
+ {x: 600, y: 0, dx: 398, dy: 831},
+ {x: 4, y: 0, dx: 596, dy: 831},
+ {x: 8, y: 552, dx: 590, dy: 276},
+ {x: 8, y: 1, dx: 590, dy: 551}
+ ]);
+ },
+ "can specify padding as a function that returns null": function(treemap) {
+ var t = treemap().size([1000, 1000]).sort(null).padding(function(d) { return d.depth & 1 ? null : 1; });
+ assert.deepEqual(t.nodes({children: [{value: 1}, {value: 2}, {children: [{value: 1}, {value: 2}]}]}).map(layout), [
+ {x: 0, y: 0, dx: 1000, dy: 1000},
+ {x: 1, y: 833, dx: 998, dy: 166},
+ {x: 600, y: 1, dx: 399, dy: 832},
+ {x: 1, y: 1, dx: 599, dy: 832},
+ {x: 1, y: 556, dx: 599, dy: 277},
+ {x: 1, y: 1, dx: 599, dy: 555}
+ ]);
+ },
+ "no negatively sized rectangles": function(treemap) {
+ var t = treemap().size([615, 500]).sort(function(a, b) { return a.value - b.value; }).padding(29),
+ data = [1, 9, 3, 15, 44, 28, 32, 41, 50, 60, 64, 75, 76, 84, 88, 100, 140, 142, 363, 657, 670, 822, 1173, 1189],
+ nodes = t.nodes({children: data.map(function(d) { return {value: d}; })}).map(layout);
+ assert.equal(nodes.filter(function(n) { return n.dx < 0 || n.dy < 0; }).length, 0);
+ },
+ "no overhanging rectangles": function(treemap) {
+ var t = treemap().size([100, 100]).sort(function(a, b) { return a.value - b.value; }),
+ data = [0, 0, 81681.85, 370881.9, 0, 0, 0, 255381.59, 0, 0, 0, 0, 0, 0, 0, 125323.95, 0, 0, 0, 186975.07, 185707.05, 267370.93, 0],
+ nodes = t.nodes({children: data.map(function(d) { return {value: d}; })}).map(layout);
+ assert.equal(nodes.filter(function(n) { return n.dx < 0 || n.dy < 0 || n.x + n.dx > 100 || n.y + n.dy > 100; }).length, 0);
+ },
+ "can handle an empty children array": function(treemap) {
+ assert.deepEqual(treemap().nodes({children: []}).map(layout), [
+ {x: 0, y: 0, dx: 1, dy: 1}
+ ]);
+ assert.deepEqual(treemap().nodes({children: [{children: []}, {value: 1}]}).map(layout), [
+ {x: 0, y: 0, dx: 1, dy: 1},
+ {x: 0, y: 0, dx: 0, dy: 1},
+ {x: 0, y: 0, dx: 1, dy: 1}
+ ]);
+ },
+ "slice-dice": function(treemap) {
+ assert.deepEqual(treemap().size([100, 10]).mode("slice-dice").nodes({children: [
+ {children: [{value: 1}, {value: 1}]},
+ {children: [{value: 1}, {value: 1}]}
+ ]}).map(layout), [
+ {x: 0, y: 0, dx: 100, dy: 10},
+ {x: 50, y: 0, dx: 50, dy: 10},
+ {x: 50, y: 5, dx: 50, dy: 5},
+ {x: 50, y: 0, dx: 50, dy: 5},
+ {x: 0, y: 0, dx: 50, dy: 10},
+ {x: 0, y: 5, dx: 50, dy: 5},
+ {x: 0, y: 0, dx: 50, dy: 5}
+ ]);
+ }
+ }
+});
+
+function layout(node) {
+ return {
+ x: node.x,
+ y: node.y,
+ dx: node.dx,
+ dy: node.dy
+ };
+}
+
+suite.export(module);