Commit 0d7c6c55 authored by Mike Bostock's avatar Mike Bostock
Browse files

Use _ to disambiguate local vs. global d3.

parent 2b3abf60
var vows = require("vows"),
d3 = require("../../"),
_ = require("../../"),
load = require("../load"),
assert = require("../assert");
......@@ -39,7 +39,7 @@ suite.addBatch({
assert.isUndefined(max([NaN, NaN]));
},
"applies the optional accessor function": function(max) {
assert.equal(max([[1, 2, 3, 4, 5], [2, 4, 6, 8, 10]], function(d) { return d3.min(d); }), 2);
assert.equal(max([[1, 2, 3, 4, 5], [2, 4, 6, 8, 10]], function(d) { return _.min(d); }), 2);
assert.equal(max([1, 2, 3, 4, 5], function(d, i) { return i; }), 4);
}
}
......
var vows = require("vows"),
d3 = require("../../"),
_ = require("../../"),
load = require("../load"),
assert = require("../assert");
......@@ -38,7 +38,7 @@ suite.addBatch({
assert.isUndefined(min([NaN, NaN]));
},
"applies the optional accessor function": function(min) {
assert.equal(min([[1, 2, 3, 4, 5], [2, 4, 6, 8, 10]], function(d) { return d3.max(d); }), 5);
assert.equal(min([[1, 2, 3, 4, 5], [2, 4, 6, 8, 10]], function(d) { return _.max(d); }), 5);
assert.equal(min([1, 2, 3, 4, 5], function(d, i) { return i; }), 0);
}
}
......
var vows = require("vows"),
d3 = require("../../"),
_ = require("../../"),
load = require("../load"),
assert = require("../assert");
......@@ -13,7 +13,7 @@ suite.addBatch({
.key(function(d) { return d.foo; })
.entries([{foo: 1}, {foo: 1}, {foo: 2}])
.map(function(d) { return d.key; })
.sort(d3.ascending);
.sort(_.ascending);
assert.deepEqual(keys, ["1", "2"]);
},
"each entry is a key-values object, with values in input order": function(nest) {
......@@ -27,7 +27,7 @@ suite.addBatch({
},
"keys can be sorted using an optional comparator": function(nest) {
var keys = nest()
.key(function(d) { return d.foo; }).sortKeys(d3.descending)
.key(function(d) { return d.foo; }).sortKeys(_.descending)
.entries([{foo: 1}, {foo: 1}, {foo: 2}])
.map(function(d) { return d.key; });
assert.deepEqual(keys, ["2", "1"]);
......@@ -45,7 +45,7 @@ suite.addBatch({
"values can be aggregated using an optional rollup": function(nest) {
var entries = nest()
.key(function(d) { return d.foo; })
.rollup(function(values) { return d3.sum(values, function(d) { return d.bar; }); })
.rollup(function(values) { return _.sum(values, function(d) { return d.bar; }); })
.entries([{foo: 1, bar: 2}, {foo: 1, bar: 0}, {foo: 1, bar: 1}, {foo: 2}]);
assert.deepEqual(entries, [
{key: "1", values: 3},
......@@ -54,8 +54,8 @@ suite.addBatch({
},
"multiple key functions can be specified": function(nest) {
var entries = nest()
.key(function(d) { return d[0]; }).sortKeys(d3.ascending)
.key(function(d) { return d[1]; }).sortKeys(d3.ascending)
.key(function(d) { return d[0]; }).sortKeys(_.ascending)
.key(function(d) { return d[1]; }).sortKeys(_.ascending)
.entries([[0, 1], [0, 2], [1, 1], [1, 2], [0, 2]]);
assert.deepEqual(entries, [
{key: "0", values: [
......@@ -70,8 +70,8 @@ suite.addBatch({
},
"the rollup function only applies to leaf values": function(nest) {
var entries = nest()
.key(function(d) { return d[0]; }).sortKeys(d3.ascending)
.key(function(d) { return d[1]; }).sortKeys(d3.ascending)
.key(function(d) { return d[0]; }).sortKeys(_.ascending)
.key(function(d) { return d[1]; }).sortKeys(_.ascending)
.rollup(function(values) { return values.length; })
.entries([[0, 1], [0, 2], [1, 1], [1, 2], [0, 2]]);
assert.deepEqual(entries, [
......@@ -87,8 +87,8 @@ suite.addBatch({
},
"the value comparator only applies to leaf values": function(nest) {
var entries = nest()
.key(function(d) { return d[0]; }).sortKeys(d3.ascending)
.key(function(d) { return d[1]; }).sortKeys(d3.ascending)
.key(function(d) { return d[0]; }).sortKeys(_.ascending)
.key(function(d) { return d[1]; }).sortKeys(_.ascending)
.sortValues(function(a, b) { return a[2] - b[2]; })
.entries([[0, 1], [0, 2, 1], [1, 1], [1, 2], [0, 2, 0]]);
assert.deepEqual(entries, [
......@@ -104,8 +104,8 @@ suite.addBatch({
},
"the key comparator only applies to the last-specified key": function(nest) {
var entries = nest()
.key(function(d) { return d[0]; }).sortKeys(d3.ascending)
.key(function(d) { return d[1]; }).sortKeys(d3.descending)
.key(function(d) { return d[0]; }).sortKeys(_.ascending)
.key(function(d) { return d[1]; }).sortKeys(_.descending)
.entries([[0, 1], [0, 2], [1, 1], [1, 2], [0, 2]]);
assert.deepEqual(entries, [
{key: "0", values: [
......@@ -118,8 +118,8 @@ suite.addBatch({
]}
]);
var entries = nest()
.key(function(d) { return d[0]; }).sortKeys(d3.descending)
.key(function(d) { return d[1]; }).sortKeys(d3.ascending)
.key(function(d) { return d[0]; }).sortKeys(_.descending)
.key(function(d) { return d[1]; }).sortKeys(_.ascending)
.entries([[0, 1], [0, 2], [1, 1], [1, 2], [0, 2]]);
assert.deepEqual(entries, [
{key: "1", values: [
......@@ -164,7 +164,7 @@ suite.addBatch({
"values can be aggregated using an optional rollup": function(nest) {
var map = nest()
.key(function(d) { return d.foo; })
.rollup(function(values) { return d3.sum(values, function(d) { return d.bar; }); })
.rollup(function(values) { return _.sum(values, function(d) { return d.bar; }); })
.map([{foo: 1, bar: 2}, {foo: 1, bar: 0}, {foo: 1, bar: 1}, {foo: 2}]);
assert.deepEqual(map, {
"1": 3,
......@@ -173,8 +173,8 @@ suite.addBatch({
},
"multiple key functions can be specified": function(nest) {
var map = nest()
.key(function(d) { return d[0]; }).sortKeys(d3.ascending)
.key(function(d) { return d[1]; }).sortKeys(d3.ascending)
.key(function(d) { return d[0]; }).sortKeys(_.ascending)
.key(function(d) { return d[1]; }).sortKeys(_.ascending)
.map([[0, 1], [0, 2], [1, 1], [1, 2], [0, 2]]);
assert.deepEqual(map, {
"0": {
......@@ -189,8 +189,8 @@ suite.addBatch({
},
"the rollup function only applies to leaf values": function(nest) {
var map = nest()
.key(function(d) { return d[0]; }).sortKeys(d3.ascending)
.key(function(d) { return d[1]; }).sortKeys(d3.ascending)
.key(function(d) { return d[0]; }).sortKeys(_.ascending)
.key(function(d) { return d[1]; }).sortKeys(_.ascending)
.rollup(function(values) { return values.length; })
.map([[0, 1], [0, 2], [1, 1], [1, 2], [0, 2]]);
assert.deepEqual(map, {
......@@ -206,8 +206,8 @@ suite.addBatch({
},
"the value comparator only applies to leaf values": function(nest) {
var map = nest()
.key(function(d) { return d[0]; }).sortKeys(d3.ascending)
.key(function(d) { return d[1]; }).sortKeys(d3.ascending)
.key(function(d) { return d[0]; }).sortKeys(_.ascending)
.key(function(d) { return d[1]; }).sortKeys(_.ascending)
.sortValues(function(a, b) { return a[2] - b[2]; })
.map([[0, 1], [0, 2, 1], [1, 1], [1, 2], [0, 2, 0]]);
assert.deepEqual(map, {
......@@ -234,7 +234,7 @@ suite.addBatch({
"a custom map implementation can be specified": function(nest) {
var map = nest()
.key(String)
.map(["hasOwnProperty", "__proto__"], d3.map);
.map(["hasOwnProperty", "__proto__"], _.map);
assert.deepEqual(map.entries(), [
{key: "hasOwnProperty", value: ["hasOwnProperty"]},
{key: "__proto__", value: ["__proto__"]}
......@@ -244,7 +244,7 @@ suite.addBatch({
var map = nest()
.key(function(d) { return d.foo; })
.key(function(d) { return d.bar; })
.map([{foo: 42, bar: "red"}], d3.map);
.map([{foo: 42, bar: "red"}], _.map);
assert.deepEqual(map.keys(), ["42"]);
assert.deepEqual(map.get("42").keys(), ["red"]);
assert.deepEqual(map.get("42").values(), [[{foo: 42, bar: "red"}]]);
......
var vows = require("vows"),
d3 = require("../../"),
_ = require("../../"),
load = require("../load"),
assert = require("assert");
......@@ -36,19 +36,19 @@ suite.addBatch({
},
"values are returned in arbitrary order": function(set) {
var s = set(["foo", "bar"]);
assert.deepEqual(s.values().sort(d3.ascending), ["bar", "foo"]);
assert.deepEqual(s.values().sort(_.ascending), ["bar", "foo"]);
var s = set(["bar", "foo"]);
assert.deepEqual(s.values().sort(d3.ascending), ["bar", "foo"]);
assert.deepEqual(s.values().sort(_.ascending), ["bar", "foo"]);
},
"observes changes via add and remove": function(set) {
var s = set(["foo", "bar"]);
assert.deepEqual(s.values().sort(d3.ascending), ["bar", "foo"]);
assert.deepEqual(s.values().sort(_.ascending), ["bar", "foo"]);
s.remove("foo");
assert.deepEqual(s.values(), ["bar"]);
s.add("bar");
assert.deepEqual(s.values(), ["bar"]);
s.add("foo");
assert.deepEqual(s.values().sort(d3.ascending), ["bar", "foo"]);
assert.deepEqual(s.values().sort(_.ascending), ["bar", "foo"]);
s.remove("bar");
assert.deepEqual(s.values(), ["foo"]);
s.remove("foo");
......
var vows = require("vows"),
d3 = require("../../"),
_ = require("../../"),
load = require("../load"),
assert = require("../assert");
......@@ -46,7 +46,7 @@ suite.addBatch({
assertHclEqual(hcl("rgb(102, 102, 0)"), 102.85124420310271, 49.44871600399321, 41.73251953866431);
},
"can convert from RGB": function(hcl) {
assertHclEqual(hcl(d3.rgb(12, 34, 56)), -89.58282792342067, 16.833655998102003, 12.65624852526134);
assertHclEqual(hcl(_.rgb(12, 34, 56)), -89.58282792342067, 16.833655998102003, 12.65624852526134);
},
"can convert from HSL": function(hcl) {
assertHclEqual(hcl(hcl(20, .8, .3)), 20, 0.8, 0.3);
......@@ -67,13 +67,13 @@ suite.addBatch({
assert.strictEqual(hcl(hcl(60, -4, 32)) + "", "#454c51");
},
"roundtrip to HSL is idempotent": function(hcl) {
assert.hslEqual(d3.hsl(hcl("steelblue")), d3.hsl("steelblue"));
assert.hslEqual(_.hsl(hcl("steelblue")), _.hsl("steelblue"));
},
"roundtrip to RGB is idempotent": function(hcl) {
assert.hslEqual(d3.rgb(hcl("steelblue")), d3.rgb("steelblue"));
assert.hslEqual(_.rgb(hcl("steelblue")), _.rgb("steelblue"));
},
"roundtrip to Lab is idempotent": function(hcl) {
assert.hslEqual(d3.lab(hcl("steelblue")), d3.lab("steelblue"));
assert.hslEqual(_.lab(hcl("steelblue")), _.lab("steelblue"));
}
}
});
......
var vows = require("vows"),
d3 = require("../../"),
_ = require("../../"),
load = require("../load"),
assert = require("../assert");
......@@ -49,7 +49,7 @@ suite.addBatch({
assert.hslEqual(hsl("rgb(102, 102, 0)"), 60, 1, .2);
},
"can convert from RGB": function(hsl) {
assert.hslEqual(hsl(d3.rgb(12, 34, 56)), 210, .647058, .133333);
assert.hslEqual(hsl(_.rgb(12, 34, 56)), 210, .647058, .133333);
},
"can convert from HSL": function(hsl) {
assert.hslEqual(hsl(hsl(20, .8, .3)), 20, .8, .3);
......
var vows = require("vows"),
d3 = require("../../"),
_ = require("../../"),
load = require("../load"),
assert = require("../assert");
......@@ -46,7 +46,7 @@ suite.addBatch({
assertLabEqual(lab("rgb(102, 102, 0)"), 41.73251953866431, -10.998411255098816, 48.21006600604577);
},
"can convert from RGB": function(lab) {
assertLabEqual(lab(d3.rgb(12, 34, 56)), 12.65624852526134, 0.12256520883417721, -16.833209795877284);
assertLabEqual(lab(_.rgb(12, 34, 56)), 12.65624852526134, 0.12256520883417721, -16.833209795877284);
},
"can convert from HSL": function(lab) {
assertLabEqual(lab(lab(20, .8, .3)), 20, 0.8, 0.3);
......@@ -67,13 +67,13 @@ suite.addBatch({
assert.strictEqual(lab(lab(60, -4, -32)) + "", "#5d95c8");
},
"roundtrip to HSL is idempotent": function(lab) {
assert.hslEqual(d3.hsl(lab("steelblue")), d3.hsl("steelblue"));
assert.hslEqual(_.hsl(lab("steelblue")), _.hsl("steelblue"));
},
"roundtrip to RGB is idempotent": function(lab) {
assert.hslEqual(d3.rgb(lab("steelblue")), d3.rgb("steelblue"));
assert.hslEqual(_.rgb(lab("steelblue")), _.rgb("steelblue"));
},
"roundtrip to HCL is idempotent": function(lab) {
assert.hslEqual(d3.hcl(lab("steelblue")), d3.hcl("steelblue"));
assert.hslEqual(_.hcl(lab("steelblue")), _.hcl("steelblue"));
}
}
});
......
var vows = require("vows"),
d3 = require("../../"),
_ = require("../../"),
load = require("../load"),
assert = require("../assert");
......@@ -60,7 +60,7 @@ suite.addBatch({
assert.rgbEqual(rgb(rgb(12, 34, 56)), 12, 34, 56);
},
"can convert from HSL": function(rgb) {
assert.rgbEqual(rgb(d3.hsl(0, 1, .5)), 255, 0, 0);
assert.rgbEqual(rgb(_.hsl(0, 1, .5)), 255, 0, 0);
},
"can convert to HSL": function(rgb) {
assert.hslEqual(rgb("red").hsl(), 0, 1, .5);
......@@ -83,7 +83,7 @@ suite.addBatch({
assert.strictEqual(rgb("hsl(60, 100%, 20%)") + "", "#666600");
assert.strictEqual(rgb("rgb(12, 34, 56)") + "", "#0c2238");
assert.strictEqual(rgb(rgb(12, 34, 56)) + "", "#0c2238");
assert.strictEqual(rgb(d3.hsl(60, 1, .2)) + "", "#666600");
assert.strictEqual(rgb(_.hsl(60, 1, .2)) + "", "#666600");
}
}
});
......
var d3 = require("../../"),
formatNumber = d3.format(",.02r"),
var d3 = require("../../");
var formatNumber = d3.format(",.02r"),
o = d3.geo.circle().angle(30).precision(.1)(),
n = 1e3,
then = Date.now();
......
var vows = require("vows"),
d3 = require("../../"),
_ = require("../../"),
load = require("../load"),
assert = require("../assert");
......@@ -53,51 +53,51 @@ suite.addBatch({
},
"graticule outline": {
"sphere": function(area) {
assert.inDelta(area(d3.geo.graticule().extent([[-180, -90], [180, 90]]).outline()), 4 * π, 1e-5);
assert.inDelta(area(_.geo.graticule().extent([[-180, -90], [180, 90]]).outline()), 4 * π, 1e-5);
},
"hemisphere": function(area) {
assert.inDelta(area(d3.geo.graticule().extent([[-180, 0], [180, 90]]).outline()), 2 * π, 1e-5);
assert.inDelta(area(_.geo.graticule().extent([[-180, 0], [180, 90]]).outline()), 2 * π, 1e-5);
},
"semilune": function(area) {
assert.inDelta(area(d3.geo.graticule().extent([[0, 0], [90, 90]]).outline()), π / 2, 1e-5);
assert.inDelta(area(_.geo.graticule().extent([[0, 0], [90, 90]]).outline()), π / 2, 1e-5);
}
},
"circles": {
"hemisphere": function(area) {
assert.inDelta(area(d3.geo.circle().angle(90)()), 2 * π, 1e-5);
assert.inDelta(area(_.geo.circle().angle(90)()), 2 * π, 1e-5);
},
"60°": function(area) {
assert.inDelta(area(d3.geo.circle().angle(60).precision(.1)()), π, 1e-5);
assert.inDelta(area(_.geo.circle().angle(60).precision(.1)()), π, 1e-5);
},
"60° North": function(area) {
assert.inDelta(area(d3.geo.circle().angle(60).precision(.1).origin([0, 90])()), π, 1e-5);
assert.inDelta(area(_.geo.circle().angle(60).precision(.1).origin([0, 90])()), π, 1e-5);
},
"45°": function(area) {
assert.inDelta(area(d3.geo.circle().angle(45).precision(.1)()), π * (2 - Math.SQRT2), 1e-5);
assert.inDelta(area(_.geo.circle().angle(45).precision(.1)()), π * (2 - Math.SQRT2), 1e-5);
},
"45° North": function(area) {
assert.inDelta(area(d3.geo.circle().angle(45).precision(.1).origin([0, 90])()), π * (2 - Math.SQRT2), 1e-5);
assert.inDelta(area(_.geo.circle().angle(45).precision(.1).origin([0, 90])()), π * (2 - Math.SQRT2), 1e-5);
},
"45° South": function(area) {
assert.inDelta(area(d3.geo.circle().angle(45).precision(.1).origin([0, -90])()), π * (2 - Math.SQRT2), 1e-5);
assert.inDelta(area(_.geo.circle().angle(45).precision(.1).origin([0, -90])()), π * (2 - Math.SQRT2), 1e-5);
},
"135°": function(area) {
assert.inDelta(area(d3.geo.circle().angle(135).precision(.1)()), π * (2 + Math.SQRT2), 1e-5);
assert.inDelta(area(_.geo.circle().angle(135).precision(.1)()), π * (2 + Math.SQRT2), 1e-5);
},
"135° North": function(area) {
assert.inDelta(area(d3.geo.circle().angle(135).precision(.1).origin([0, 90])()), π * (2 + Math.SQRT2), 1e-5);
assert.inDelta(area(_.geo.circle().angle(135).precision(.1).origin([0, 90])()), π * (2 + Math.SQRT2), 1e-5);
},
"135° South": function(area) {
assert.inDelta(area(d3.geo.circle().angle(135).precision(.1).origin([0, -90])()), π * (2 + Math.SQRT2), 1e-5);
assert.inDelta(area(_.geo.circle().angle(135).precision(.1).origin([0, -90])()), π * (2 + Math.SQRT2), 1e-5);
},
"tiny": function(area) {
assert.inDelta(area(d3.geo.circle().angle(1e-6).precision(.1)()), 0, 1e-6);
assert.inDelta(area(_.geo.circle().angle(1e-6).precision(.1)()), 0, 1e-6);
},
"huge": function(area) {
assert.inDelta(area(d3.geo.circle().angle(180 - 1e-6).precision(.1)()), 4 * π, 1e-6);
assert.inDelta(area(_.geo.circle().angle(180 - 1e-6).precision(.1)()), 4 * π, 1e-6);
},
"60° with 45° hole": function(area) {
var circle = d3.geo.circle().precision(.1);
var circle = _.geo.circle().precision(.1);
assert.inDelta(area({
type: "Polygon",
coordinates: [
......@@ -107,7 +107,7 @@ suite.addBatch({
}), π * (Math.SQRT2 - 1), 1e-5);
},
"45° holes at [0°, 0°] and [0°, 90°]": function(area) {
var circle = d3.geo.circle().precision(.1).angle(45);
var circle = _.geo.circle().precision(.1).angle(45);
assert.inDelta(area({
type: "Polygon",
coordinates: [
......@@ -117,7 +117,7 @@ suite.addBatch({
}), π * 2 * Math.SQRT2, 1e-5);
},
"45° holes at [0°, 90°] and [0°, 0°]": function(area) {
var circle = d3.geo.circle().precision(.1).angle(45);
var circle = _.geo.circle().precision(.1).angle(45);
assert.inDelta(area({
type: "Polygon",
coordinates: [
......@@ -129,13 +129,13 @@ suite.addBatch({
},
"stripes": {
"45°, -45°": function(area) {
assert.inDelta(area(stripes(d3, 45, -45)), π * 2 * Math.SQRT2, 1e-5);
assert.inDelta(area(stripes(45, -45)), π * 2 * Math.SQRT2, 1e-5);
},
"-45°, 45°": function(area) {
assert.inDelta(area(stripes(d3, -45, 45)), π * 2 * (2 - Math.SQRT2), 1e-5);
assert.inDelta(area(stripes(-45, 45)), π * 2 * (2 - Math.SQRT2), 1e-5);
},
"45°, 30°": function(area) {
assert.inDelta(area(stripes(d3, 45, 30)), π * (Math.SQRT2 - 1), 1e-5);
assert.inDelta(area(stripes(45, 30)), π * (Math.SQRT2 - 1), 1e-5);
}
}
},
......@@ -164,9 +164,9 @@ suite.addBatch({
suite.export(module);
function stripes(d3, a, b) {
function stripes(a, b) {
return {type: "Polygon", coordinates: [a, b].map(function(d, i) {
var stripe = d3.range(-180, 180, .1).map(function(x) { return [x, d]; });
var stripe = _.range(-180, 180, .1).map(function(x) { return [x, d]; });
stripe.push(stripe[0]);
return i ? stripe.reverse() : stripe;
})};
......
var vows = require("vows"),
d3 = require("../../"),
_ = require("../../"),
load = require("../load"),
assert = require("../assert");
......@@ -43,8 +43,8 @@ suite.addBatch({
},
"Polygon": function(centroid) {
assert.inDelta(centroid({type: "Polygon", coordinates: [[[0, -90], [0, 0], [0, 90], [1, 0], [0, -90]]]}), [.5, 0], 1e-6);
//assert.inDelta(centroid(d3.geo.circle().angle(5).origin([0, 45])()), [0, 45], 1e-6);
assert.equal(centroid({type: "Polygon", coordinates: [d3.range(-180, 180 + 1 / 2, 1).map(function(x) { return [x, -60]; })]})[1], -90);
assert.inDelta(centroid(_.geo.circle().angle(5).origin([0, 45])()), [0, 45], 1e-6);
assert.equal(centroid({type: "Polygon", coordinates: [_.range(-180, 180 + 1 / 2, 1).map(function(x) { return [x, -60]; })]})[1], -90);
assert.inDelta(centroid({type: "Polygon", coordinates: [[[0, -10], [0, 10], [10, 10], [10, -10], [0, -10]]]}), [5, 0], 1e-6);
},
"MultiPolygon": function(centroid) {
......
var vows = require("vows"),
d3 = require("../../"),
_ = require("../../"),
load = require("../load"),
assert = require("../assert");
......@@ -16,7 +16,7 @@ suite.addBatch({
"origin([0, 90])": function(circle) {
var o = circle().origin([0, 90])();
assert.equal(o.type, "Polygon");
assert.inDelta(o.coordinates, [d3.range(360, -1, -6).map(function(x) { return [x >= 180 ? x - 360 : x, 0]; })], 1e-6);
assert.inDelta(o.coordinates, [_.range(360, -1, -6).map(function(x) { return [x >= 180 ? x - 360 : x, 0]; })], 1e-6);
},
"origin([45, 45])": function(circle) {
var o = circle().origin([45, 45]).angle(0)();
......
var vows = require("vows"),
d3 = require("../../"),
_ = require("../../"),
load = require("../load"),
assert = require("../assert");
......@@ -121,7 +121,7 @@ suite.addBatch({
.filter(function(line) { return line.coordinates[0][0] === line.coordinates[1][0]; })
.filter(function(line) { return Math.abs(line.coordinates[0][0] % 90) > ε; });
lines.forEach(function(line) {
assert.deepEqual(d3.extent(line.coordinates, function(p) { return p[1]; }), [-80 - ε, +80 + ε]);
assert.deepEqual(_.extent(line.coordinates, function(p) { return p[1]; }), [-80 - ε, +80 + ε]);
});
},
"default major longitude lines extend from 90°S to 90°N": function(graticule) {
......@@ -129,14 +129,14 @@ suite.addBatch({
.filter(function(line) { return line.coordinates[0][0] === line.coordinates[1][0]; })
.filter(function(line) { return Math.abs(line.coordinates[0][0] % 90) < ε; });
lines.forEach(function(line) {
assert.deepEqual(d3.extent(line.coordinates, function(p) { return p[1]; }), [-90 + ε, +90 - ε]);
assert.deepEqual(_.extent(line.coordinates, function(p) { return p[1]; }), [-90 + ε, +90 - ε]);
});
},
"default latitude lines extend from 180°W to 180°E": function(graticule) {
var lines = graticule().lines()
.filter(function(line) { return line.coordinates[0][1] === line.coordinates[1][1]; });
lines.forEach(function(line) {
assert.deepEqual(d3.extent(line.coordinates, function(p) { return p[0]; }), [-180, +180]);
assert.deepEqual(_.extent(line.coordinates, function(p) { return p[0]; }), [-180, +180]);
});
},
"returns an array of LineStrings": function(graticule) {
......
var vows = require("vows"),
d3 = require("../../"),
_ = require("../../"),
load = require("../load"),
assert = require("../assert");
......@@ -13,7 +13,7 @@ suite.addBatch({
topic: function(path) {
return path()
.context(testContext)
.projection(d3.geo.equirectangular()
.projection(_.geo.equirectangular()
.scale(900 / Math.PI)
.precision(0));
},
......@@ -261,7 +261,7 @@ suite.addBatch({
"with the default context (null) and an identity projection": {
topic: function(path) {
return path()
.projection(d3.geo.equirectangular()
.projection(_.geo.equirectangular()
.scale(900 / Math.PI)
.precision(0));
},
......@@ -307,7 +307,7 @@ suite.addBatch({
topic: function(path) {
return path()
.context(testContext)
.projection(d3.geo.equirectangular()
.projection(_.geo.equirectangular()
.rotate([-180, -248])
.scale(900 / Math.PI)
.precision(0));
......@@ -320,7 +320,7 @@ suite.addBatch({
"projection": {
"returns the current projection when called with no arguments": function(path) {
var p = path(), projection = d3.geo.equirectangular();
var p = path(), projection = _.geo.equirectangular();
p.projection(projection);
assert.strictEqual(p.projection(), projection);
}
......@@ -351,7 +351,7 @@ suite.addBatch({
topic: function(path) {
return path()
.context(testContext)
.projection(d3.geo.equirectangular()
.projection(_.geo.equirectangular()
.scale(900 / Math.PI)
.precision(0)
.clipAngle(90));
......@@ -385,22 +385,22 @@ suite.addBatch({