Commit 43d09afd authored by Mike Bostock's avatar Mike Bostock
Browse files

Merge branch '3.1.5'

parents ea284ebf 80a1dd6f
{
"name": "d3",
"version": "3.1.4",
"version": "3.1.5",
"main": "index-browserify.js",
"scripts": [
"index-browserify.js",
......
d3 = function() {
var d3 = {
version: "3.1.4"
version: "3.1.5"
};
if (!Date.now) Date.now = function() {
return +new Date();
......@@ -409,6 +409,16 @@ d3 = function() {
while (s = e.sourceEvent) e = s;
return e;
}
function d3_eventSuppress(target, type) {
function off() {
target.on(type, null);
}
target.on(type, function() {
d3_eventCancel();
off();
}, true);
setTimeout(off, 0);
}
function d3_eventDispatch(target) {
var dispatch = new d3_dispatch(), i = 0, n = arguments.length;
while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch);
......@@ -524,14 +534,10 @@ d3 = function() {
});
if (moved) {
d3_eventCancel();
if (d3.event.target === eventTarget) w.on("click.drag", click, true);
if (d3.event.target === eventTarget) d3_eventSuppress(w, "click");
}
w.on(touchId != null ? "touchmove.drag-" + touchId : "mousemove.drag", null).on(touchId != null ? "touchend.drag-" + touchId : "mouseup.drag", null);
}
function click() {
d3_eventCancel();
w.on("click.drag", null);
}
}
drag.origin = function(x) {
if (!arguments.length) return origin;
......@@ -1171,11 +1177,7 @@ d3 = function() {
function mouseup() {
if (moved) d3_eventCancel();
w.on("mousemove.zoom", null).on("mouseup.zoom", null);
if (moved && d3.event.target === eventTarget) w.on("click.zoom", click, true);
}
function click() {
d3_eventCancel();
w.on("click.zoom", null);
if (moved && d3.event.target === eventTarget) d3_eventSuppress(w, "click.zoom");
}
}
function mousewheel() {
......@@ -2002,14 +2004,14 @@ d3 = function() {
}
d3.geo = {};
d3.geo.stream = function(object, listener) {
if (d3_geo_streamObjectType.hasOwnProperty(object.type)) {
if (object && d3_geo_streamObjectType.hasOwnProperty(object.type)) {
d3_geo_streamObjectType[object.type](object, listener);
} else {
d3_geo_streamGeometry(object, listener);
}
};
function d3_geo_streamGeometry(geometry, listener) {
if (d3_geo_streamGeometryType.hasOwnProperty(geometry.type)) {
if (geometry && d3_geo_streamGeometryType.hasOwnProperty(geometry.type)) {
d3_geo_streamGeometryType[geometry.type](geometry, listener);
}
}
......@@ -4683,7 +4685,7 @@ d3 = function() {
};
d3.interpolateNumber = d3_interpolateNumber;
function d3_interpolateNumber(a, b) {
b -= a;
b -= a = +a;
return function(t) {
return a + b * t;
};
......@@ -4764,6 +4766,7 @@ d3 = function() {
d3.interpolateString = d3_interpolateString;
function d3_interpolateString(a, b) {
var m, i, j, s0 = 0, s1 = 0, s = [], q = [], n, o;
a = a + "", b = b + "";
d3_interpolate_number.lastIndex = 0;
for (i = 0; m = d3_interpolate_number.exec(b); ++i) {
if (m.index) s.push(b.substring(s0, s1 = m.index));
......@@ -4834,14 +4837,9 @@ d3 = function() {
function d3_interpolateByName(name) {
return name == "transform" ? d3_interpolateTransform : d3_interpolate;
}
d3.interpolators = [ d3_interpolateObject, function(a, b) {
return Array.isArray(b) && d3_interpolateArray(a, b);
}, function(a, b) {
return (typeof a === "string" || typeof b === "string") && d3_interpolateString(a + "", b + "");
}, function(a, b) {
return (typeof b === "string" ? d3_rgb_names.has(b) || /^(#|rgb\(|hsl\()/.test(b) : b instanceof d3_Color) && d3_interpolateRgb(a, b);
}, function(a, b) {
return !isNaN(a = +a) && !isNaN(b = +b) && d3_interpolateNumber(a, b);
d3.interpolators = [ function(a, b) {
var t = typeof b;
return (t === "string" || t !== typeof a ? d3_rgb_names.has(b) || /^(#|rgb\(|hsl\()/.test(b) ? d3_interpolateRgb : d3_interpolateString : b instanceof d3_Color ? d3_interpolateRgb : t === "object" ? Array.isArray(b) ? d3_interpolateArray : d3_interpolateObject : d3_interpolateNumber)(a, b);
} ];
d3.interpolateArray = d3_interpolateArray;
function d3_interpolateArray(a, b) {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "d3",
"version": "3.1.4",
"version": "3.1.5",
"description": "A small, free JavaScript library for manipulating documents based on data.",
"keywords": [
"dom",
......
......@@ -65,18 +65,12 @@ d3.behavior.drag = function() {
// if moved, prevent the mouseup (and possibly click) from propagating
if (moved) {
d3_eventCancel();
if (d3.event.target === eventTarget) w.on("click.drag", click, true);
if (d3.event.target === eventTarget) d3_eventSuppress(w, "click");
}
w .on(touchId != null ? "touchmove.drag-" + touchId : "mousemove.drag", null)
.on(touchId != null ? "touchend.drag-" + touchId : "mouseup.drag", null);
}
// prevent the subsequent click from propagating (e.g., for anchors)
function click() {
d3_eventCancel();
w.on("click.drag", null);
}
}
drag.origin = function(x) {
......
......@@ -116,12 +116,7 @@ d3.behavior.zoom = function() {
function mouseup() {
if (moved) d3_eventCancel();
w.on("mousemove.zoom", null).on("mouseup.zoom", null);
if (moved && d3.event.target === eventTarget) w.on("click.zoom", click, true);
}
function click() {
d3_eventCancel();
w.on("click.zoom", null);
if (moved && d3.event.target === eventTarget) d3_eventSuppress(w, "click.zoom");
}
}
......
......@@ -13,6 +13,15 @@ function d3_eventSource() {
return e;
}
// Registers an event listener for the specified target that cancels the next
// event for the specified type, but only if it occurs immediately. This is
// useful to disambiguate dragging from clicking.
function d3_eventSuppress(target, type) {
function off() { target.on(type, null); }
target.on(type, function() { d3_eventCancel(); off(); }, true);
setTimeout(off, 0); // clear the handler if it doesn't fire
}
// Like d3.dispatch, but for custom events abstracting native UI events. These
// events have a target component (such as a brush), a target element (such as
// the svg:g element containing the brush) and the standard arguments `d` (the
......
import "geo";
d3.geo.stream = function(object, listener) {
if (d3_geo_streamObjectType.hasOwnProperty(object.type)) {
if (object && d3_geo_streamObjectType.hasOwnProperty(object.type)) {
d3_geo_streamObjectType[object.type](object, listener);
} else {
d3_geo_streamGeometry(object, listener);
......@@ -9,7 +9,7 @@ d3.geo.stream = function(object, listener) {
};
function d3_geo_streamGeometry(geometry, listener) {
if (d3_geo_streamGeometryType.hasOwnProperty(geometry.type)) {
if (geometry && d3_geo_streamGeometryType.hasOwnProperty(geometry.type)) {
d3_geo_streamGeometryType[geometry.type](geometry, listener);
}
}
......
......@@ -22,9 +22,11 @@ function d3_interpolateByName(name) {
}
d3.interpolators = [
d3_interpolateObject,
function(a, b) { return Array.isArray(b) && d3_interpolateArray(a, b); },
function(a, b) { return (typeof a === "string" || typeof b === "string") && d3_interpolateString(a + "", b + ""); },
function(a, b) { return (typeof b === "string" ? d3_rgb_names.has(b) || /^(#|rgb\(|hsl\()/.test(b) : b instanceof d3_Color) && d3_interpolateRgb(a, b); },
function(a, b) { return !isNaN(a = +a) && !isNaN(b = +b) && d3_interpolateNumber(a, b); }
function(a, b) {
var t = typeof b;
return (t === "string" || t !== typeof a ? (d3_rgb_names.has(b) || /^(#|rgb\(|hsl\()/.test(b) ? d3_interpolateRgb : d3_interpolateString)
: b instanceof d3_Color ? d3_interpolateRgb
: t === "object" ? (Array.isArray(b) ? d3_interpolateArray : d3_interpolateObject)
: d3_interpolateNumber)(a, b);
}
];
d3.interpolateNumber = d3_interpolateNumber;
function d3_interpolateNumber(a, b) {
b -= a;
b -= a = +a;
return function(t) { return a + b * t; };
}
......@@ -13,6 +13,9 @@ function d3_interpolateString(a, b) {
n, // q.length
o;
// Coerce inputs to strings.
a = a + "", b = b + "";
// Reset our regular expression!
d3_interpolate_number.lastIndex = 0;
......
d3 = (function(){
var d3 = {version: "3.1.4"}; // semver
var d3 = {version: "3.1.5"}; // semver
......@@ -2,6 +2,12 @@ var assert = require("assert");
assert = module.exports = Object.create(assert);
assert.isArray = function(actual, message) {
if (!Array.isArray(actual)) {
assert.fail(actual, null, message || "expected {actual} to be an Array", null, assert.isArray);
}
};
assert.inDelta = function(actual, expected, delta, message) {
if (!inDelta(actual, expected, delta)) {
assert.fail(actual, expected, message || "expected {actual} to be in within *" + delta + "* of {expected}", null, assert.inDelta);
......
......@@ -19,6 +19,12 @@ suite.addBatch({
stream({type: "FeatureCollection", features: [{type: "Feature", geometry: {type: "Unknown"}}]}, {});
stream({type: "GeometryCollection", geometries: [{type: "Unknown"}]}, {});
},
"ignores null geometries": function(stream) {
stream(null, {});
stream({type: "Feature", geometry: null}, {});
stream({type: "FeatureCollection", features: [{type: "Feature", geometry: null}]}, {});
stream({type: "GeometryCollection", geometries: [null]}, {});
},
"returns void": function(stream) {
assert.isUndefined(stream({type: "Point", coordinates: [1, 2]}, {point: function() { return true; }}));
},
......
......@@ -49,37 +49,37 @@ suite.addBatch({
},
"invalid eases and modes default to linear-in": function(ease) {
var e = ease("__proto__-__proto__");
assert.equal(e(0), 0);
assert.equal(e(.5), .5);
assert.equal(e(1), 1);
assert.strictEqual(e(0), 0);
assert.strictEqual(e(.5), .5);
assert.strictEqual(e(1), 1);
var e = ease("hasOwnProperty-constructor");
assert.equal(e(0), 0);
assert.equal(e(.5), .5);
assert.equal(e(1), 1);
assert.strictEqual(e(0), 0);
assert.strictEqual(e(.5), .5);
assert.strictEqual(e(1), 1);
},
"all easing functions return exactly 0 for t = 0": function(ease) {
assert.equal(ease("linear")(0), 0);
assert.equal(ease("poly", 2)(0), 0);
assert.equal(ease("quad")(0), 0);
assert.equal(ease("cubic")(0), 0);
assert.equal(ease("sin")(0), 0);
assert.equal(ease("exp")(0), 0);
assert.equal(ease("circle")(0), 0);
assert.equal(ease("elastic")(0), 0);
assert.equal(ease("back")(0), 0);
assert.equal(ease("bounce")(0), 0);
assert.strictEqual(ease("linear")(0), 0);
assert.strictEqual(ease("poly", 2)(0), 0);
assert.strictEqual(ease("quad")(0), 0);
assert.strictEqual(ease("cubic")(0), 0);
assert.strictEqual(ease("sin")(0), 0);
assert.strictEqual(ease("exp")(0), 0);
assert.strictEqual(ease("circle")(0), 0);
assert.strictEqual(ease("elastic")(0), 0);
assert.strictEqual(ease("back")(0), 0);
assert.strictEqual(ease("bounce")(0), 0);
},
"all easing functions return exactly 1 for t = 1": function(ease) {
assert.equal(ease("linear")(1), 1);
assert.equal(ease("poly", 2)(1), 1);
assert.equal(ease("quad")(1), 1);
assert.equal(ease("cubic")(1), 1);
assert.equal(ease("sin")(1), 1);
assert.equal(ease("exp")(1), 1);
assert.equal(ease("circle")(1), 1);
assert.equal(ease("elastic")(1), 1);
assert.equal(ease("back")(1), 1);
assert.equal(ease("bounce")(1), 1);
assert.strictEqual(ease("linear")(1), 1);
assert.strictEqual(ease("poly", 2)(1), 1);
assert.strictEqual(ease("quad")(1), 1);
assert.strictEqual(ease("cubic")(1), 1);
assert.strictEqual(ease("sin")(1), 1);
assert.strictEqual(ease("exp")(1), 1);
assert.strictEqual(ease("circle")(1), 1);
assert.strictEqual(ease("elastic")(1), 1);
assert.strictEqual(ease("back")(1), 1);
assert.strictEqual(ease("bounce")(1), 1);
},
"the -in suffix returns the identity": function(ease) {
assert.inDelta(ease("linear-in")(.25), ease("linear")(.25), 1e-6);
......
......@@ -8,22 +8,22 @@ suite.addBatch({
"interpolateHsl": {
topic: load("interpolate/hsl"), // beware instanceof d3_Color
"parses string input": function(d3) {
assert.equal(d3.interpolateHsl("steelblue", "#f00")(.2), "#383dc3");
assert.equal(d3.interpolateHsl("steelblue", "#f00")(.6), "#dd1ce1");
assert.strictEqual(d3.interpolateHsl("steelblue", "#f00")(.2), "#383dc3");
assert.strictEqual(d3.interpolateHsl("steelblue", "#f00")(.6), "#dd1ce1");
},
"parses d3.hsl input": function(d3) {
assert.equal(d3.interpolateHsl(d3.hsl("steelblue"), "#f00")(.2), "#383dc3");
assert.equal(d3.interpolateHsl("steelblue", d3.hsl(0, 1, .5))(.6), "#dd1ce1");
assert.strictEqual(d3.interpolateHsl(d3.hsl("steelblue"), "#f00")(.2), "#383dc3");
assert.strictEqual(d3.interpolateHsl("steelblue", d3.hsl(0, 1, .5))(.6), "#dd1ce1");
},
"parses d3.rgb input": function(d3) {
assert.equal(d3.interpolateHsl(d3.rgb("steelblue"), "#f00")(.2), "#383dc3");
assert.equal(d3.interpolateHsl("steelblue", d3.rgb(255, 0, 0))(.6), "#dd1ce1");
assert.strictEqual(d3.interpolateHsl(d3.rgb("steelblue"), "#f00")(.2), "#383dc3");
assert.strictEqual(d3.interpolateHsl("steelblue", d3.rgb(255, 0, 0))(.6), "#dd1ce1");
},
"interpolates in HSL color space": function(d3) {
assert.equal(d3.interpolateHsl("steelblue", "#f00")(.2), "#383dc3");
assert.strictEqual(d3.interpolateHsl("steelblue", "#f00")(.2), "#383dc3");
},
"outputs a hexadecimal string": function(d3) {
assert.equal(d3.interpolateHsl("steelblue", "#f00")(.2), "#383dc3");
assert.strictEqual(d3.interpolateHsl("steelblue", "#f00")(.2), "#383dc3");
}
}
});
......
......@@ -7,26 +7,102 @@ var suite = vows.describe("d3.interpolate");
suite.addBatch({
"interpolate": {
topic: load("interpolate/interpolate").document(),
"interpolates numbers": function(d3) {
assert.equal(d3.interpolate(2, 12)(.4), 6);
assert.equal(d3.interpolate("2px", 12)(.4), 6);
"when a and b are numbers": {
"interpolates numbers": function(d3) {
assert.strictEqual(d3.interpolate(2, 12)(.4), 6);
}
},
"when a and b are color strings": {
"interpolates RGB values and returns a hexadecimal string": function(d3) {
assert.strictEqual(d3.interpolate("#ff0000", "#008000")(.4), "#993300");
},
"interpolates named colors in RGB": function(d3) {
assert.strictEqual(d3.interpolate("red", "green")(.4), "#993300");
},
"interpolates decimal RGB colors in RGB": function(d3) {
assert.strictEqual(d3.interpolate("rgb(255,0,0)", "rgb(0,128,0)")(.4), "#993300");
},
"interpolates decimal HSL colors in RGB": function(d3) {
assert.strictEqual(d3.interpolate("hsl(0,100%,50%)", "hsl(120,100%,25%)")(.4), "#993300");
}
},
"interpolates colors": function(d3) { // beware instanceof d3_Color
assert.equal(d3.interpolate("#abcdef", "#fedcba")(.4), "#ccd3da");
assert.equal(d3.interpolate("#abcdef", d3.rgb("#fedcba"))(.4), "#ccd3da");
assert.equal(d3.interpolate("#abcdef", d3.hsl("#fedcba"))(.4), "#ccd3da");
assert.equal(d3.interpolate("#abcdef", d3.lab("#fedcba"))(.4), "#ccd3da");
"when a and b are color objects": {
"interpolates RGB values and returns a hexadecimal string": function(d3) {
assert.strictEqual(d3.interpolate(d3.rgb(255, 0, 0), d3.rgb(0, 128, 0))(.4), "#993300");
},
"interpolates d3.hsl in RGB": function(d3) {
assert.strictEqual(d3.interpolate(d3.hsl("red"), d3.hsl("green"))(.4), "#993300");
},
"interpolates d3.lab in RGB": function(d3) {
assert.strictEqual(d3.interpolate(d3.lab("red"), d3.lab("green"))(.4), "#993300");
},
"interpolates d3.hcl in RGB": function(d3) {
assert.strictEqual(d3.interpolate(d3.hcl("red"), d3.hcl("green"))(.4), "#993300");
}
},
"when a and b are strings": {
"interpolates matching numbers in both strings": function(d3) {
assert.strictEqual(d3.interpolate(" 10/20 30", "50/10 100 ")(.4), "26/16 58 ");
},
"if a and b are coercible to numbers, interpolates numbers rather than strings": function(d3) {
assert.strictEqual(d3.interpolate("1.", "2.")(.5), 1.5);
assert.strictEqual(d3.interpolate("1e+3", "1e+4")(.5), 5500);
},
"preserves non-numbers in string b": function(d3) {
assert.strictEqual(d3.interpolate(" 10/20 30", "50/10 foo ")(.4), "26/16 foo ");
},
"preserves non-matching numbers in string b": function(d3) {
assert.strictEqual(d3.interpolate(" 10/20 bar", "50/10 100 ")(.4), "26/16 100 ");
},
"preserves equal-value numbers in both strings": function(d3) {
assert.strictEqual(d3.interpolate(" 10/20 100 20", "50/10 100, 20 ")(.4), "26/16 100, 20 ");
}
},
"interpolates strings": function(d3) {
assert.equal(d3.interpolate("width:10px;", "width:50px;")(.2), "width:18px;");
assert.equal(d3.interpolate(2, "12px")(.4), "6px");
"when a and b are arrays": {
"interpolates each element in b": function(d3) {
assert.strictEqual(JSON.stringify(d3.interpolate([2, 4], [12, 24])(.4)), "[6,12]");
},
"interpolates arrays, even when both a and b are coercible to numbers": function(d3) {
assert.strictEqual(JSON.stringify(d3.interpolate([2], [12])(.4)), "[6]");
assert.strictEqual(JSON.stringify(d3.interpolate([[2]], [[12]])(.4)), "[[6]]");
},
"reuses the returned array during interpolation": function(d3) {
var i = d3.interpolate([2], [12]);
assert.strictEqual(i(.2), i(.4));
}
},
"interpolates arrays": function(d3) {
assert.deepEqual(d3.interpolate([2, 4], [12, 24])(.4), [6, 12]);
"when a and b are objects": {
"interpolates each property in b": function(d3) {
assert.deepEqual(d3.interpolate({foo: 2, bar: 4}, {foo: 12, bar: 24})(.4), {foo: 6, bar: 12});
},
"interpolates arrays, even when both a and b are coercible to numbers": function(d3) {
var two = new Number(2), twelve = new Number(12);
two.foo = "2px";
twelve.foo = "12px";
assert.deepEqual(d3.interpolate(two, twelve)(.4), {foo: "6px"});
},
"reuses the returned object during interpolation": function(d3) {
var i = d3.interpolate({foo: 2, bar: 4}, {foo: 12, bar: 24});
assert.strictEqual(i(.2), i(.4));
}
},
"interpolates objects": function(d3) {
assert.deepEqual(d3.interpolate({foo: 2}, {foo: 12})(.4), {foo: 6});
"when a and b are different types": {
"coerces both types to strings": function(d3) {
assert.strictEqual(d3.interpolate("2", 12)(.4), 6);
assert.strictEqual(d3.interpolate("2px", 12)(.4), 6);
assert.strictEqual(d3.interpolate([2], 12)(.4), 6);
assert.strictEqual(d3.interpolate({valueOf: function() { return 2; }}, 12)(.4), 6);
assert.strictEqual(d3.interpolate({toString: function() { return 2; }}, 12)(.4), 6);
}
},
"may or may not interpolate between enumerable and non-enumerable properties": function(d3) {
var a = Object.create({}, {foo: {value: 1, enumerable: true}}),
b = Object.create({}, {foo: {value: 2, enumerable: false}});
......@@ -50,17 +126,20 @@ suite.addBatch({
assert.equal(d3.interpolate("hasOwnProperty", "hasOwnProperty")(0), "hasOwnProperty");
}
},
"interpolators": {
topic: load("interpolate/interpolate").document(),
"can register a custom interpolator": function(d3) {
d3.interpolators.push(function(a, b) {
return a == "one" && b == "two" && d3.interpolateNumber(1, 2);
});
assert.equal(d3.interpolate("one", "two")(-.5), .5);
assert.equal(d3.interpolate("one", "two")(0), 1);
assert.equal(d3.interpolate("one", "two")(.5), 1.5);
assert.equal(d3.interpolate("one", "two")(1), 2);
assert.equal(d3.interpolate("one", "two")(1.5), 2.5);
d3.interpolators.push(function(a, b) { return a == "one" && b == "two" && d3.interpolateNumber(1, 2); });
try {
assert.equal(d3.interpolate("one", "two")(-.5), .5);
assert.equal(d3.interpolate("one", "two")(0), 1);
assert.equal(d3.interpolate("one", "two")(.5), 1.5);
assert.equal(d3.interpolate("one", "two")(1), 2);
assert.equal(d3.interpolate("one", "two")(1.5), 2.5);
} finally {
d3.interpolators.pop();
}
}
}
});
......
......@@ -23,35 +23,35 @@ suite.addBatch({
return d3;
},
"identity": function(d3) {
assert.equal(d3.interpolateTransform([0, 0, 0, 0, 1, 1] + "", [0, 0, 0, 0, 1, 1] + "")(.4), "");
assert.strictEqual(d3.interpolateTransform([0, 0, 0, 0, 1, 1] + "", [0, 0, 0, 0, 1, 1] + "")(.4), "");
},
"translate": {
"x": function(d3) {
assert.equal(d3.interpolateTransform([0, 0, 0, 0, 1, 1] + "", [10, 0, 0, 0, 1, 1] + "")(.4), "translate(4,0)");
assert.strictEqual(d3.interpolateTransform([0, 0, 0, 0, 1, 1] + "", [10, 0, 0, 0, 1, 1] + "")(.4), "translate(4,0)");
},
"y": function(d3) {
assert.equal(d3.interpolateTransform([0, 0, 0, 0, 1, 1] + "", [0, 10, 0, 0, 1, 1] + "")(.4), "translate(0,4)");
assert.strictEqual(d3.interpolateTransform([0, 0, 0, 0, 1, 1] + "", [0, 10, 0, 0, 1, 1] + "")(.4), "translate(0,4)");
},
"x and y": function(d3) {
assert.equal(d3.interpolateTransform([0, 0, 0, 0, 1, 1] + "", [1, 10, 0, 0, 1, 1] + "")(.4), "translate(0.4,4)");
assert.strictEqual(d3.interpolateTransform([0, 0, 0, 0, 1, 1] + "", [1, 10, 0, 0, 1, 1] + "")(.4), "translate(0.4,4)");
}
},
"rotate": {
"simple": function(d3) {
assert.equal(d3.interpolateTransform([0, 0, -10, 0, 1, 1] + "", [0, 0, 30, 0, 1, 1] + "")(.4), "rotate(6)");
assert.strictEqual(d3.interpolateTransform([0, 0, -10, 0, 1, 1] + "", [0, 0, 30, 0, 1, 1] + "")(.4), "rotate(6)");
},
"with constant translate": function(d3) {
assert.equal(d3.interpolateTransform([5, 6, -10, 0, 1, 1] + "", [5, 6, 30, 0, 1, 1] + "")(.4), "translate(5,6)rotate(6)");
assert.strictEqual(d3.interpolateTransform([5, 6, -10, 0, 1, 1] + "", [5, 6, 30, 0, 1, 1] + "")(.4), "translate(5,6)rotate(6)");
}
},
"skew": function(d3) {
assert.equal(d3.interpolateTransform([0, 0, 0, 0, 1, 1] + "", [0, 0, 0, 40, 1, 1] + "")(.4), "skewX(16)");
assert.strictEqual(d3.interpolateTransform([0, 0, 0, 0, 1, 1] + "", [0, 0, 0, 40, 1, 1] + "")(.4), "skewX(16)");
},
"scale": function(d3) {
assert.equal(d3.interpolateTransform([0, 0, 0, 0, 1, 1] + "", [0, 0, 0, 0, 10, 1] + "")(.5), "scale(5.5,1)");
assert.strictEqual(d3.interpolateTransform([0, 0, 0, 0, 1, 1] + "", [0, 0, 0, 0, 10, 1] + "")(.5), "scale(5.5,1)");
},
"translate and rotate": function(d3) {
assert.equal(d3.interpolateTransform([0, 0, 0, 0, 1, 1] + "", [100, 0, 90, 0, 1, 1] + "")(.5), "translate(50,0)rotate(45)");
assert.strictEqual(d3.interpolateTransform([0, 0, 0, 0, 1, 1] + "", [100, 0, 90, 0, 1, 1] + "")(.5), "translate(50,0)rotate(45)");
}
}
}
......
......@@ -8,8 +8,11 @@ suite.addBatch({
"interpolateNumber": {
topic: load("interpolate/number").expression("d3.interpolateNumber"),
"interpolates numbers": function(interpolate) {
assert.equal(interpolate(2, 12)(.4), 6);