Merge branch '3.2.8'
This commit is contained in:
Коммит
23ee2c08a6
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "d3",
|
||||
"version": "3.2.7",
|
||||
"version": "3.2.8",
|
||||
"main": "d3.js",
|
||||
"scripts": [
|
||||
"d3.js"
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
"animation",
|
||||
"canvas"
|
||||
],
|
||||
"version": "3.2.7",
|
||||
"version": "3.2.8",
|
||||
"main": "index-browserify.js",
|
||||
"scripts": [
|
||||
"d3.js",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
d3 = function() {
|
||||
var d3 = {
|
||||
version: "3.2.7"
|
||||
version: "3.2.8"
|
||||
};
|
||||
if (!Date.now) Date.now = function() {
|
||||
return +new Date();
|
||||
|
@ -131,8 +131,8 @@ d3 = function() {
|
|||
return array;
|
||||
};
|
||||
d3.permute = function(array, indexes) {
|
||||
var permutes = [], i = -1, n = indexes.length;
|
||||
while (++i < n) permutes[i] = array[indexes[i]];
|
||||
var i = indexes.length, permutes = new Array(i);
|
||||
while (i--) permutes[i] = array[indexes[i]];
|
||||
return permutes;
|
||||
};
|
||||
d3.zip = function() {
|
||||
|
@ -204,7 +204,9 @@ d3 = function() {
|
|||
}
|
||||
d3.map = function(object) {
|
||||
var map = new d3_Map();
|
||||
for (var key in object) map.set(key, object[key]);
|
||||
if (object instanceof d3_Map) object.forEach(function(key, value) {
|
||||
map.set(key, value);
|
||||
}); else for (var key in object) map.set(key, object[key]);
|
||||
return map;
|
||||
};
|
||||
function d3_Map() {}
|
||||
|
@ -320,7 +322,7 @@ d3 = function() {
|
|||
};
|
||||
d3.set = function(array) {
|
||||
var set = new d3_Set();
|
||||
if (array) for (var i = 0; i < array.length; i++) set.add(array[i]);
|
||||
if (array) for (var i = 0, n = array.length; i < n; ++i) set.add(array[i]);
|
||||
return set;
|
||||
};
|
||||
function d3_Set() {}
|
||||
|
@ -374,8 +376,8 @@ d3 = function() {
|
|||
var d3_vendorPrefixes = [ "webkit", "ms", "moz", "Moz", "o", "O" ];
|
||||
var d3_array = d3_arraySlice;
|
||||
function d3_arrayCopy(pseudoarray) {
|
||||
var i = -1, n = pseudoarray.length, array = [];
|
||||
while (++i < n) array.push(pseudoarray[i]);
|
||||
var i = pseudoarray.length, array = new Array(i);
|
||||
while (i--) array[i] = pseudoarray[i];
|
||||
return array;
|
||||
}
|
||||
function d3_arraySlice(pseudoarray) {
|
||||
|
@ -855,7 +857,7 @@ d3 = function() {
|
|||
function d3_selection_sortComparator(comparator) {
|
||||
if (!arguments.length) comparator = d3.ascending;
|
||||
return function(a, b) {
|
||||
return !a - !b || comparator(a.__data__, b.__data__);
|
||||
return a && b ? comparator(a.__data__, b.__data__) : !a - !b;
|
||||
};
|
||||
}
|
||||
d3_selectionPrototype.each = function(callback) {
|
||||
|
@ -1152,9 +1154,9 @@ d3 = function() {
|
|||
return d3.rebind(drag, event, "on");
|
||||
};
|
||||
d3.behavior.zoom = function() {
|
||||
var translate = [ 0, 0 ], translate0, scale = 1, scaleExtent = d3_behavior_zoomInfinity, mousedown = "mousedown.zoom", mousemove = "mousemove.zoom", mouseup = "mouseup.zoom", event = d3_eventDispatch(zoom, "zoom"), x0, x1, y0, y1, touchtime;
|
||||
var translate = [ 0, 0 ], translate0, scale = 1, scaleExtent = d3_behavior_zoomInfinity, mousedown = "mousedown.zoom", mousemove = "mousemove.zoom", mouseup = "mouseup.zoom", touchstart = "touchstart.zoom", touchmove = "touchmove.zoom", touchend = "touchend.zoom", touchtime, event = d3_eventDispatch(zoom, "zoom"), x0, x1, y0, y1;
|
||||
function zoom() {
|
||||
this.on(mousedown, mousedowned).on(d3_behavior_zoomWheel + ".zoom", mousewheeled).on(mousemove, mousewheelreset).on("dblclick.zoom", dblclicked).on("touchstart.zoom", touchstarted);
|
||||
this.on(mousedown, mousedowned).on(d3_behavior_zoomWheel + ".zoom", mousewheeled).on(mousemove, mousewheelreset).on("dblclick.zoom", dblclicked).on(touchstart, touchstarted);
|
||||
}
|
||||
zoom.translate = function(x) {
|
||||
if (!arguments.length) return translate;
|
||||
|
@ -1232,27 +1234,37 @@ d3 = function() {
|
|||
}
|
||||
}
|
||||
function touchstarted() {
|
||||
var target = this, event_ = event.of(target, arguments), touches = d3.touches(target), locations = {}, distance0 = 0, scale0 = scale, now = Date.now(), name = "zoom-" + d3.event.changedTouches[0].identifier, touchmove = "touchmove." + name, touchend = "touchend." + name, w = d3.select(d3_window).on(touchmove, moved).on(touchend, ended), t = d3.select(target).on(mousedown, null), dragRestore = d3_event_dragSuppress();
|
||||
touches.forEach(function(t) {
|
||||
locations[t.identifier] = location(t);
|
||||
});
|
||||
if (touches.length === 1) {
|
||||
if (now - touchtime < 500) {
|
||||
var p = touches[0], l = location(touches[0]);
|
||||
scaleTo(scale * 2);
|
||||
translateTo(p, l);
|
||||
d3_eventPreventDefault();
|
||||
dispatch(event_);
|
||||
var target = this, event_ = event.of(target, arguments), locations0, distance0 = 0, scale0, w = d3.select(d3_window).on(touchmove, moved).on(touchend, ended), t = d3.select(target).on(mousedown, null).on(touchstart, started), dragRestore = d3_event_dragSuppress();
|
||||
started();
|
||||
function relocate() {
|
||||
var touches = d3.touches(target);
|
||||
scale0 = scale;
|
||||
locations0 = {};
|
||||
touches.forEach(function(t) {
|
||||
locations0[t.identifier] = location(t);
|
||||
});
|
||||
return touches;
|
||||
}
|
||||
function started() {
|
||||
var now = Date.now(), touches = relocate();
|
||||
if (touches.length === 1) {
|
||||
if (now - touchtime < 500) {
|
||||
var p = touches[0], l = locations0[p.identifier];
|
||||
scaleTo(scale * 2);
|
||||
translateTo(p, l);
|
||||
d3_eventPreventDefault();
|
||||
dispatch(event_);
|
||||
}
|
||||
touchtime = now;
|
||||
} else if (touches.length > 1) {
|
||||
var p = touches[0], q = touches[1], dx = p[0] - q[0], dy = p[1] - q[1];
|
||||
distance0 = dx * dx + dy * dy;
|
||||
}
|
||||
touchtime = now;
|
||||
} else if (touches.length > 1) {
|
||||
var p = touches[0], q = touches[1], dx = p[0] - q[0], dy = p[1] - q[1];
|
||||
distance0 = dx * dx + dy * dy;
|
||||
}
|
||||
function moved() {
|
||||
var touches = d3.touches(target), p0 = touches[0], l0 = locations[p0.identifier];
|
||||
var touches = d3.touches(target), p0 = touches[0], l0 = locations0[p0.identifier];
|
||||
if (p1 = touches[1]) {
|
||||
var p1, l1 = locations[p1.identifier], scale1 = d3.event.scale;
|
||||
var p1, l1 = locations0[p1.identifier], scale1 = d3.event.scale;
|
||||
if (scale1 == null) {
|
||||
var distance1 = (distance1 = p1[0] - p0[0]) * distance1 + (distance1 = p1[1] - p0[1]) * distance1;
|
||||
scale1 = distance0 && Math.sqrt(distance1 / distance0);
|
||||
|
@ -1266,9 +1278,13 @@ d3 = function() {
|
|||
dispatch(event_);
|
||||
}
|
||||
function ended() {
|
||||
w.on(touchmove, null).on(touchend, null);
|
||||
t.on(mousedown, mousedowned);
|
||||
dragRestore();
|
||||
if (d3.event.touches.length) {
|
||||
relocate();
|
||||
} else {
|
||||
w.on(touchmove, null).on(touchend, null);
|
||||
t.on(mousedown, mousedowned).on(touchstart, touchstarted);
|
||||
dragRestore();
|
||||
}
|
||||
}
|
||||
}
|
||||
function mousewheeled() {
|
||||
|
@ -6843,9 +6859,8 @@ d3 = function() {
|
|||
return scale;
|
||||
};
|
||||
scale.ticks = function() {
|
||||
var extent = d3_scaleExtent(domain), ticks = [];
|
||||
if (extent.every(isFinite)) {
|
||||
var u = extent[0], v = extent[1], i = Math.floor(log(u)), j = Math.ceil(log(v)), n = base % 1 ? 2 : base;
|
||||
var extent = d3_scaleExtent(domain), ticks = [], u = extent[0], v = extent[1], i = Math.floor(log(u)), j = Math.ceil(log(v)), n = base % 1 ? 2 : base;
|
||||
if (isFinite(j - i)) {
|
||||
if (positive) {
|
||||
for (;i < j; i++) for (var k = 1; k < n; k++) ticks.push(pow(i) * k);
|
||||
ticks.push(pow(i));
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "d3",
|
||||
"version": "3.2.7",
|
||||
"version": "3.2.8",
|
||||
"description": "A small, free JavaScript library for manipulating documents based on data.",
|
||||
"keywords": [
|
||||
"dom",
|
||||
|
|
|
@ -2,7 +2,8 @@ import "../core/class";
|
|||
|
||||
d3.map = function(object) {
|
||||
var map = new d3_Map;
|
||||
for (var key in object) map.set(key, object[key]);
|
||||
if (object instanceof d3_Map) object.forEach(function(key, value) { map.set(key, value); });
|
||||
else for (var key in object) map.set(key, object[key]);
|
||||
return map;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
d3.permute = function(array, indexes) {
|
||||
var permutes = [],
|
||||
i = -1,
|
||||
n = indexes.length;
|
||||
while (++i < n) permutes[i] = array[indexes[i]];
|
||||
var i = indexes.length, permutes = new Array(i);
|
||||
while (i--) permutes[i] = array[indexes[i]];
|
||||
return permutes;
|
||||
};
|
||||
|
|
|
@ -2,8 +2,8 @@ import "../core/class";
|
|||
import "map";
|
||||
|
||||
d3.set = function(array) {
|
||||
var set = new d3_Set();
|
||||
if (array) for (var i = 0; i < array.length; i++) set.add(array[i]);
|
||||
var set = new d3_Set;
|
||||
if (array) for (var i = 0, n = array.length; i < n; ++i) set.add(array[i]);
|
||||
return set;
|
||||
};
|
||||
|
||||
|
|
|
@ -15,19 +15,22 @@ d3.behavior.zoom = function() {
|
|||
mousedown = "mousedown.zoom",
|
||||
mousemove = "mousemove.zoom",
|
||||
mouseup = "mouseup.zoom",
|
||||
touchstart = "touchstart.zoom",
|
||||
touchmove = "touchmove.zoom",
|
||||
touchend = "touchend.zoom",
|
||||
touchtime, // time of last touchstart (to detect double-tap)
|
||||
event = d3_eventDispatch(zoom, "zoom"),
|
||||
x0,
|
||||
x1,
|
||||
y0,
|
||||
y1,
|
||||
touchtime; // time of last touchstart (to detect double-tap)
|
||||
y1;
|
||||
|
||||
function zoom() {
|
||||
this.on(mousedown, mousedowned)
|
||||
.on(d3_behavior_zoomWheel + ".zoom", mousewheeled)
|
||||
.on(mousemove, mousewheelreset)
|
||||
.on("dblclick.zoom", dblclicked)
|
||||
.on("touchstart.zoom", touchstarted);
|
||||
.on(touchstart, touchstarted);
|
||||
}
|
||||
|
||||
zoom.translate = function(x) {
|
||||
|
@ -117,45 +120,55 @@ d3.behavior.zoom = function() {
|
|||
}
|
||||
}
|
||||
|
||||
// These closures persist for as long as at least one touch is active.
|
||||
function touchstarted() {
|
||||
var target = this,
|
||||
event_ = event.of(target, arguments),
|
||||
touches = d3.touches(target),
|
||||
locations = {},
|
||||
locations0, // touchstart locations
|
||||
distance0 = 0, // distance² between initial touches
|
||||
scale0 = scale, // scale when we started touching
|
||||
now = Date.now(),
|
||||
name = "zoom-" + d3.event.changedTouches[0].identifier,
|
||||
touchmove = "touchmove." + name,
|
||||
touchend = "touchend." + name,
|
||||
scale0, // scale when we started touching
|
||||
w = d3.select(d3_window).on(touchmove, moved).on(touchend, ended),
|
||||
t = d3.select(target).on(mousedown, null), // prevent duplicate events
|
||||
t = d3.select(target).on(mousedown, null).on(touchstart, started), // prevent duplicate events
|
||||
dragRestore = d3_event_dragSuppress();
|
||||
|
||||
touches.forEach(function(t) { locations[t.identifier] = location(t); });
|
||||
started();
|
||||
|
||||
if (touches.length === 1) {
|
||||
if (now - touchtime < 500) { // dbltap
|
||||
var p = touches[0], l = location(touches[0]);
|
||||
scaleTo(scale * 2);
|
||||
translateTo(p, l);
|
||||
d3_eventPreventDefault();
|
||||
dispatch(event_);
|
||||
function relocate() {
|
||||
var touches = d3.touches(target);
|
||||
scale0 = scale;
|
||||
locations0 = {};
|
||||
touches.forEach(function(t) { locations0[t.identifier] = location(t); });
|
||||
return touches;
|
||||
}
|
||||
|
||||
// Temporarily override touchstart while gesture is active.
|
||||
function started() {
|
||||
var now = Date.now(),
|
||||
touches = relocate();
|
||||
|
||||
if (touches.length === 1) {
|
||||
if (now - touchtime < 500) { // dbltap
|
||||
var p = touches[0], l = locations0[p.identifier];
|
||||
scaleTo(scale * 2);
|
||||
translateTo(p, l);
|
||||
d3_eventPreventDefault();
|
||||
dispatch(event_);
|
||||
}
|
||||
touchtime = now;
|
||||
} else if (touches.length > 1) {
|
||||
var p = touches[0], q = touches[1],
|
||||
dx = p[0] - q[0], dy = p[1] - q[1];
|
||||
distance0 = dx * dx + dy * dy;
|
||||
}
|
||||
touchtime = now;
|
||||
} else if (touches.length > 1) {
|
||||
var p = touches[0], q = touches[1],
|
||||
dx = p[0] - q[0], dy = p[1] - q[1];
|
||||
distance0 = dx * dx + dy * dy;
|
||||
}
|
||||
|
||||
function moved() {
|
||||
var touches = d3.touches(target),
|
||||
p0 = touches[0],
|
||||
l0 = locations[p0.identifier];
|
||||
l0 = locations0[p0.identifier];
|
||||
|
||||
if (p1 = touches[1]) {
|
||||
var p1, l1 = locations[p1.identifier],
|
||||
var p1, l1 = locations0[p1.identifier],
|
||||
scale1 = d3.event.scale;
|
||||
if (scale1 == null) {
|
||||
var distance1 = (distance1 = p1[0] - p0[0]) * distance1 + (distance1 = p1[1] - p0[1]) * distance1;
|
||||
|
@ -172,9 +185,13 @@ d3.behavior.zoom = function() {
|
|||
}
|
||||
|
||||
function ended() {
|
||||
w.on(touchmove, null).on(touchend, null);
|
||||
t.on(mousedown, mousedowned);
|
||||
dragRestore();
|
||||
if (d3.event.touches.length) {
|
||||
relocate(); // locations may have detached due to rotation
|
||||
} else {
|
||||
w.on(touchmove, null).on(touchend, null);
|
||||
t.on(mousedown, mousedowned).on(touchstart, touchstarted);
|
||||
dragRestore();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@ import "document";
|
|||
var d3_array = d3_arraySlice; // conversion for NodeLists
|
||||
|
||||
function d3_arrayCopy(pseudoarray) {
|
||||
var i = -1, n = pseudoarray.length, array = [];
|
||||
while (++i < n) array.push(pseudoarray[i]);
|
||||
var i = pseudoarray.length, array = new Array(i);
|
||||
while (i--) array[i] = pseudoarray[i];
|
||||
return array;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,13 +48,13 @@ function d3_scale_log(linear, base, positive, domain) {
|
|||
|
||||
scale.ticks = function() {
|
||||
var extent = d3_scaleExtent(domain),
|
||||
ticks = [];
|
||||
if (extent.every(isFinite)) {
|
||||
var u = extent[0],
|
||||
v = extent[1],
|
||||
i = Math.floor(log(u)),
|
||||
j = Math.ceil(log(v)),
|
||||
n = base % 1 ? 2 : base;
|
||||
ticks = [],
|
||||
u = extent[0],
|
||||
v = extent[1],
|
||||
i = Math.floor(log(u)),
|
||||
j = Math.ceil(log(v)),
|
||||
n = base % 1 ? 2 : base;
|
||||
if (isFinite(j - i)) {
|
||||
if (positive) {
|
||||
for (; i < j; i++) for (var k = 1; k < n; k++) ticks.push(pow(i) * k);
|
||||
ticks.push(pow(i));
|
||||
|
|
|
@ -10,6 +10,6 @@ d3_selectionPrototype.sort = function(comparator) {
|
|||
function d3_selection_sortComparator(comparator) {
|
||||
if (!arguments.length) comparator = d3.ascending;
|
||||
return function(a, b) {
|
||||
return (!a - !b) || comparator(a.__data__, b.__data__);
|
||||
return a && b ? comparator(a.__data__, b.__data__) : !a - !b;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
d3 = (function(){
|
||||
var d3 = {version: "3.2.7"}; // semver
|
||||
var d3 = {version: "3.2.8"}; // semver
|
||||
|
|
|
@ -41,6 +41,14 @@ suite.addBatch({
|
|||
var m = map(Object.create(null, {foo: {value: 42, enumerable: false}}));
|
||||
assert.isFalse(m.has("foo"));
|
||||
assert.isUndefined(m.get("foo"));
|
||||
},
|
||||
"map(map) copies the given map": function(map) {
|
||||
var a = map({foo: 42}),
|
||||
b = map(a);
|
||||
assert.isTrue(b.has("foo"));
|
||||
assert.equal(b.get("foo"), 42);
|
||||
a.set("bar", true);
|
||||
assert.isFalse(b.has("bar"));
|
||||
}
|
||||
},
|
||||
"forEach": {
|
||||
|
|
|
@ -247,6 +247,15 @@ suite.addBatch({
|
|||
"100", "200", "300", "", "", "", "", "", "",
|
||||
"1k"
|
||||
]);
|
||||
},
|
||||
"generates empty ticks when the domain is degenerate": function(d3) {
|
||||
var x = d3.scale.log();
|
||||
assert.deepEqual(x.domain([0, 1]).ticks(), []);
|
||||
assert.deepEqual(x.domain([1, 0]).ticks(), []);
|
||||
assert.deepEqual(x.domain([0, -1]).ticks(), []);
|
||||
assert.deepEqual(x.domain([-1, 0]).ticks(), []);
|
||||
assert.deepEqual(x.domain([-1, 1]).ticks(), []);
|
||||
assert.deepEqual(x.domain([0, 0]).ticks(), []);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -44,18 +44,18 @@ suite.addBatch({
|
|||
"sorts null nodes at the end of the selection": function(span) {
|
||||
var nulls = 0;
|
||||
span[0][0].parentNode.removeChild(span[0][0]);
|
||||
span[0][0] = null;
|
||||
span[0][2].parentNode.removeChild(span[0][2]);
|
||||
span[0][0] = span[0][2] = null;
|
||||
span.sort(function(a, b) { if ((a === null) || (b === null)) ++nulls; return a - b; });
|
||||
assert.equal(nulls, 0);
|
||||
|
||||
assert.isNull(span[0][3]);
|
||||
assert.domNull(span[0][2]);
|
||||
assert.domNull(span[0][3]);
|
||||
assert.domNull(span[0][0].previousSibling);
|
||||
assert.domEqual(span[0][1], span[0][0].nextSibling);
|
||||
assert.domEqual(span[0][0], span[0][1].previousSibling);
|
||||
assert.domEqual(span[0][2], span[0][1].nextSibling);
|
||||
assert.domEqual(span[0][1], span[0][2].previousSibling);
|
||||
assert.domNull(span[0][2].nextSibling);
|
||||
assert.deepEqual(span[0].slice(0, -1).map(data), [3, 10, 21]);
|
||||
assert.domNull(span[0][1].nextSibling);
|
||||
assert.deepEqual(span[0].slice(0, -2).map(data), [3, 21]);
|
||||
|
||||
for (var i = 1; i < 4; ++i) {
|
||||
var d = span[i].parentNode.__data__;
|
||||
|
|
Загрузка…
Ссылка в новой задаче