Comparing version 2.9.6 to 2.9.7
{ | ||
"name": "d3", | ||
"version": "2.9.6", | ||
"version": "2.9.7", | ||
"description": "A small, free JavaScript library for manipulating documents based on data.", | ||
@@ -30,3 +30,4 @@ "keywords": [ | ||
"uglify-js": "1.2.3", | ||
"vows": "0.6.x" | ||
"vows": "0.6.x", | ||
"canvas": "0.12.1" | ||
}, | ||
@@ -33,0 +34,0 @@ "scripts": { |
@@ -139,9 +139,11 @@ d3.behavior.zoom = function() { | ||
if ((touches.length === 1) && (now - touchtime < 500)) { // dbltap | ||
var p = touches[0], l = location(touches[0]); | ||
scaleTo(scale * 2); | ||
translateTo(p, l); | ||
dispatch(event.of(this, arguments)); | ||
if (touches.length === 1) { | ||
if (now - touchtime < 500) { // dbltap | ||
var p = touches[0], l = location(touches[0]); | ||
scaleTo(scale * 2); | ||
translateTo(p, l); | ||
dispatch(event.of(this, arguments)); | ||
} | ||
touchtime = now; | ||
} | ||
touchtime = now; | ||
} | ||
@@ -160,2 +162,3 @@ | ||
translateTo(p0, l0); | ||
touchtime = null; | ||
dispatch(event.of(this, arguments)); | ||
@@ -162,0 +165,0 @@ } |
@@ -7,3 +7,3 @@ d3.bisector = function(f) { | ||
while (lo < hi) { | ||
var mid = lo + hi >> 1; | ||
var mid = lo + hi >>> 1; | ||
if (f.call(a, a[mid], mid) < x) lo = mid + 1; | ||
@@ -18,3 +18,3 @@ else hi = mid; | ||
while (lo < hi) { | ||
var mid = lo + hi >> 1; | ||
var mid = lo + hi >>> 1; | ||
if (x < f.call(a, a[mid], mid)) hi = mid; | ||
@@ -21,0 +21,0 @@ else lo = mid + 1; |
@@ -1,1 +0,1 @@ | ||
d3 = {version: "2.9.6"}; // semver | ||
d3 = {version: "2.9.7"}; // semver |
@@ -20,3 +20,3 @@ d3.interpolate = function(a, b) { | ||
i, // current index | ||
j, // current index (for coallescing) | ||
j, // current index (for coalescing) | ||
s0 = 0, // start index of current string prefix | ||
@@ -44,3 +44,3 @@ s1 = 0, // end index of current string prefix | ||
o = q[i]; | ||
if (o.x == m[0]) { // The numbers match, so coallesce. | ||
if (o.x == m[0]) { // The numbers match, so coalesce. | ||
if (o.i) { | ||
@@ -51,3 +51,3 @@ if (s[o.i + 1] == null) { // This match is followed by another number. | ||
for (j = i + 1; j < n; ++j) q[j].i--; | ||
} else { // This match is followed by a string, so coallesce twice. | ||
} else { // This match is followed by a string, so coalesce twice. | ||
s[o.i - 1] += o.x + s[o.i + 1]; | ||
@@ -60,3 +60,3 @@ s.splice(o.i, 2); | ||
s[o.i] = o.x; | ||
} else { // This match is followed by a string, so coallesce twice. | ||
} else { // This match is followed by a string, so coalesce twice. | ||
s[o.i] = o.x + s[o.i + 1]; | ||
@@ -80,3 +80,3 @@ s.splice(o.i + 1, 1); | ||
s[o.i] = o.x; | ||
} else { // This match is followed by a string, so coallesce twice. | ||
} else { // This match is followed by a string, so coalesce twice. | ||
s[o.i] = o.x + s[o.i + 1]; | ||
@@ -101,2 +101,4 @@ s.splice(o.i + 1, 1); | ||
d3.interpolateTransform = function(a, b) { | ||
if ((n = d3_interpolateTransformSimilar(a, b))) return n; | ||
var s = [], // string constants and placeholders | ||
@@ -153,2 +155,108 @@ q = [], // number interpolators | ||
var d3_interpolateTransformTypes = [ | ||
"", | ||
"", | ||
"translate", | ||
"scale", | ||
"rotate", | ||
"skewX", | ||
"skewY" | ||
]; | ||
// If both the ‘from’ and ‘to’ transforms have the same number of transform | ||
// functions and corresponding functions in each transform list are of the same | ||
// type, each transform function is animated with its corresponding destination | ||
// function in isolation using the rules described above. The individual values | ||
// are then applied as a list to produce resulting transform value. | ||
var d3_interpolateTransformSimilar = function(a, b) { | ||
var ga = document.createElementNS(d3.ns.prefix.svg, "g"), | ||
gb = document.createElementNS(d3.ns.prefix.svg, "g"); | ||
return (d3_interpolateTransformSimilar = function(a, b) { | ||
ga.setAttribute("transform", a); | ||
gb.setAttribute("transform", b); | ||
a = ga.transform.baseVal; | ||
b = gb.transform.baseVal; | ||
var sa = [], | ||
sb = [], | ||
i = -1, | ||
n = a.numberOfItems, | ||
m = b.numberOfItems, | ||
ta, | ||
tb, | ||
type; | ||
// If one of the ‘from’ or ‘to’ transforms is "none", the ‘none’ is replaced | ||
// by an equivalent identity function list for the corresponding transform | ||
// function list. Otherwise, if the transform function lists do not have the | ||
// same number of items, the transforms are each converted into the | ||
// equivalent matrix value and animation proceeds using the rule for a | ||
// single function above. | ||
if (m !== n) { | ||
if (!m) b = d3_interpolateTransformIdentity(a); | ||
else if (!n) a = d3_interpolateTransformIdentity(b), n = m; | ||
else return; | ||
} | ||
// If both the ‘from’ and ‘to’ transforms are "none", there is no | ||
// interpolation necessary. | ||
else if (!m) return; | ||
while (++i < n) { | ||
ta = a.getItem(i); | ||
tb = b.getItem(i); | ||
type = ta.type; | ||
// If the transform functions are not the same type, or the type is | ||
// unknown, fallback to the decomposed transform transition. | ||
if (type !== tb.type || !type) return; // unknown | ||
switch (type) { | ||
// For matrix, the matrix is decomposed using the method described by | ||
// unmatrix into separate translation, scale, rotation and skew | ||
// matrices, then each decomposed matrix is interpolated numerically, | ||
// and finally combined in order to produce a resulting 3x2 matrix. | ||
case 1: { // matrix | ||
sa.push(new d3_transform(ta.matrix)); | ||
sb.push(new d3_transform(tb.matrix)); | ||
continue; | ||
} | ||
// For translate, scale, rotate and skew functions the individual | ||
// components of the function are interpolated numerically. | ||
case 2: { // translate | ||
ra = ta.matrix.e + "," + ta.matrix.f; | ||
rb = tb.matrix.e + "," + tb.matrix.f; | ||
break; | ||
} | ||
case 3: { // scale | ||
ra = ta.matrix.a + "," + ta.matrix.d; | ||
rb = tb.matrix.a + "," + tb.matrix.d; | ||
break; | ||
} | ||
default: { // rotate, skew | ||
ra = ta.angle; | ||
rb = tb.angle; | ||
} | ||
} | ||
sa.push(type = d3_interpolateTransformTypes[type], "(", ra, ")"); | ||
sb.push(type, "(", rb, ")"); | ||
} | ||
return d3.interpolateString(sa.join(""), sb.join("")); | ||
})(a, b); | ||
}; | ||
function d3_interpolateTransformIdentity(a) { | ||
return { | ||
getItem: function(i) { | ||
return { | ||
type: a.getItem(i).type, | ||
angle: 0, | ||
matrix: d3_transformIdentity | ||
}; | ||
} | ||
}; | ||
} | ||
d3.interpolateRgb = function(a, b) { | ||
@@ -223,3 +331,3 @@ a = d3.rgb(a); | ||
}; | ||
} | ||
}; | ||
@@ -226,0 +334,0 @@ var d3_interpolate_number = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g; |
@@ -44,5 +44,7 @@ d3_selectionPrototype.classed = function(name, value) { | ||
cv = cb ? c.baseVal : c; | ||
cv = d3_collapse(cv.replace(re, " ")); | ||
if (cb) c.baseVal = cv; | ||
else this.className = cv; | ||
if (cv) { | ||
cv = d3_collapse(cv.replace(re, " ")); | ||
if (cb) c.baseVal = cv; | ||
else this.className = cv; | ||
} | ||
} | ||
@@ -49,0 +51,0 @@ |
@@ -14,4 +14,5 @@ // type can be namespaced, e.g., "click.foo" | ||
// remove the old event listener, and add the new event listener | ||
return this.each(function(d, i) { | ||
return this.each(function() { | ||
var node = this, | ||
args = arguments, | ||
o = node[name]; | ||
@@ -31,8 +32,9 @@ | ||
// wrapped event listener that preserves i | ||
// wrapped event listener that propagates data changes | ||
function l(e) { | ||
var o = d3.event; // Events can be reentrant (e.g., focus). | ||
d3.event = e; | ||
args[0] = node.__data__; | ||
try { | ||
listener.call(node, node.__data__, i); | ||
listener.apply(node, args); | ||
} finally { | ||
@@ -39,0 +41,0 @@ d3.event = o; |
d3.transform = function(string) { | ||
var g = document.createElementNS(d3.ns.prefix.svg, "g"), | ||
identity = {a: 1, b: 0, c: 0, d: 1, e: 0, f: 0}; | ||
var g = document.createElementNS(d3.ns.prefix.svg, "g"); | ||
return (d3.transform = function(string) { | ||
g.setAttribute("transform", string); | ||
var t = g.transform.baseVal.consolidate(); | ||
return new d3_transform(t ? t.matrix : identity); | ||
return new d3_transform(t ? t.matrix : d3_transformIdentity); | ||
})(string); | ||
@@ -60,2 +59,3 @@ }; | ||
var d3_transformDegrees = 180 / Math.PI; | ||
var d3_transformDegrees = 180 / Math.PI, | ||
d3_transformIdentity = {a: 1, b: 0, c: 0, d: 1, e: 0, f: 0}; |
@@ -184,7 +184,7 @@ d3.layout.pack = function() { | ||
var da = b.r + c.r, | ||
dc = Math.sqrt(dx * dx + dy * dy), | ||
cos = Math.max(-1, Math.min(1, (db * db + dc * dc - da * da) / (2 * db * dc))), | ||
theta = Math.acos(cos), | ||
x = cos * (db /= dc), | ||
y = Math.sin(theta) * db; | ||
dc = dx * dx + dy * dy; | ||
da *= da; | ||
db *= db; | ||
var x = .5 + (db - da) / (2 * dc), | ||
y = Math.sqrt(Math.max(0, 2 * da * (db + dc) - (db -= dc) * db - da * da)) / (2 * dc); | ||
c.x = a.x + x * dx + y * dy; | ||
@@ -191,0 +191,0 @@ c.y = a.y + x * dy - y * dx; |
@@ -19,5 +19,6 @@ require("./core/core"); | ||
"uglify-js": "1.2.3", | ||
"vows": "0.6.x" | ||
"vows": "0.6.x", | ||
"canvas": "0.12.1" // for node-canvas example | ||
}, | ||
"scripts": {"test": "./node_modules/vows/bin/vows"} | ||
}, null, 2)); |
@@ -89,2 +89,3 @@ function d3_svg_line(projection) { | ||
"linear": d3_svg_lineLinear, | ||
"linear-closed": d3_svg_lineLinearClosed, | ||
"step-before": d3_svg_lineStepBefore, | ||
@@ -104,10 +105,9 @@ "step-after": d3_svg_lineStepAfter, | ||
function d3_svg_lineLinear(points) { | ||
var i = 0, | ||
n = points.length, | ||
p = points[0], | ||
path = [p[0], ",", p[1]]; | ||
while (++i < n) path.push("L", (p = points[i])[0], ",", p[1]); | ||
return path.join(""); | ||
return points.join("L"); | ||
} | ||
function d3_svg_lineLinearClosed(points) { | ||
return d3_svg_lineLinear(points) + "Z"; | ||
} | ||
// Step interpolation; generates "H" and "V" commands. | ||
@@ -114,0 +114,0 @@ function d3_svg_lineStepBefore(points) { |
d3.time.day = d3_time_interval(function(date) { | ||
return new d3_time(date.getFullYear(), date.getMonth(), date.getDate()); | ||
var day = new d3_time(0, date.getMonth(), date.getDate()); | ||
day.setFullYear(date.getFullYear()); | ||
return day; | ||
}, function(date, offset) { | ||
@@ -14,3 +16,3 @@ date.setDate(date.getDate() + offset); | ||
var year = d3.time.year(date); | ||
return Math.floor((date - year) / 864e5 - (date.getTimezoneOffset() - year.getTimezoneOffset()) / 1440); | ||
return Math.floor((date - year - (date.getTimezoneOffset() - year.getTimezoneOffset()) * 6e4) / 864e5); | ||
}; |
@@ -218,7 +218,7 @@ d3.time.format = function(template) { | ||
var n = d3_time_numberRe.exec(string.substring(i, i + 2)); | ||
return n ? (date.y = d3_time_century() + +n[0], i += n[0].length) : -1; | ||
return n ? (date.y = d3_time_expandYear(+n[0]), i += n[0].length) : -1; | ||
} | ||
function d3_time_century() { | ||
return ~~(new Date().getFullYear() / 1000) * 1000; | ||
function d3_time_expandYear(d) { | ||
return d + (d > 68 ? 1900 : 2000); | ||
} | ||
@@ -225,0 +225,0 @@ |
d3.time.month = d3_time_interval(function(date) { | ||
return new d3_time(date.getFullYear(), date.getMonth(), 1); | ||
date = d3.time.day(date); | ||
date.setDate(1); | ||
return date; | ||
}, function(date, offset) { | ||
@@ -4,0 +6,0 @@ date.setMonth(date.getMonth() + offset); |
d3.time.year = d3_time_interval(function(date) { | ||
return new d3_time(date.getFullYear(), 0, 1); | ||
date = d3.time.day(date); | ||
date.setMonth(0, 1); | ||
return date; | ||
}, function(date, offset) { | ||
@@ -4,0 +6,0 @@ date.setFullYear(date.getFullYear() + offset); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
614808
3
15710