upgraded to d3 2.9, also minor change to multibar accessor

master-patched
Bob Monteverde 12 years ago
parent 07b90e80f5
commit 634518c73c

294
lib/d3.v2.js vendored

@ -10,7 +10,7 @@ try {
d3_style_setProperty.call(this, name, value + "", priority);
};
}
d3 = {version: "2.8.1"}; // semver
d3 = {version: "2.9.2"}; // semver
function d3_class(ctor, properties) {
try {
for (var key in properties) {
@ -100,12 +100,20 @@ d3_class(d3_Map, {
var d3_map_prefix = "\0", // prevent collision with built-ins
d3_map_prefixCode = d3_map_prefix.charCodeAt(0);
function d3_identity(d) {
return d;
}
function d3_this() {
return this;
}
d3.functor = function(v) {
function d3_true() {
return true;
}
function d3_functor(v) {
return typeof v === "function" ? v : function() { return v; };
};
}
d3.functor = d3_functor;
// Copies a variable number of methods from source to target.
d3.rebind = function(target, source) {
var i = 1, n = arguments.length, method;
@ -484,7 +492,10 @@ d3.xhr = function(url, mime, callback) {
req.open("GET", url, true);
if (mime) req.setRequestHeader("Accept", mime);
req.onreadystatechange = function() {
if (req.readyState === 4) callback(req.status < 300 ? req : null);
if (req.readyState === 4) {
var s = req.status;
callback(s >= 200 && s < 300 || s === 304 ? req : null);
}
};
req.send(null);
};
@ -650,7 +661,7 @@ d3.format = function(specifier) {
// Apply the scale, computing it from the value's exponent for si format.
if (scale < 0) {
var prefix = d3.formatPrefix(value, precision);
value *= prefix.scale;
value = prefix.scale(value);
suffix = prefix.symbol;
} else {
value *= scale;
@ -719,12 +730,12 @@ d3.formatPrefix = function(value, precision) {
};
function d3_formatPrefix(d, i) {
var k = Math.pow(10, Math.abs(8 - i) * 3);
return {
scale: Math.pow(10, (8 - i) * 3),
scale: i > 8 ? function(d) { return d / k; } : function(d) { return d * k; },
symbol: d
};
}
/*
* TERMS OF USE - EASING EQUATIONS
*
@ -1120,7 +1131,7 @@ d3.interpolateObject = function(a, b) {
};
}
var d3_interpolate_number = /[-+]?(?:\d*\.?\d+)(?:[eE][-+]?\d+)?/g;
var d3_interpolate_number = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g;
function d3_interpolateByName(n) {
return n == "transform"
@ -2150,8 +2161,8 @@ function d3_transition(groups, id, time) {
lock.active = id;
tweens.forEach(function(key, value) {
if (tween = value.call(node, d, i)) {
tweened.push(tween);
if (value = value.call(node, d, i)) {
tweened.push(value);
}
});
@ -3185,25 +3196,25 @@ d3.svg.arc = function() {
arc.innerRadius = function(v) {
if (!arguments.length) return innerRadius;
innerRadius = d3.functor(v);
innerRadius = d3_functor(v);
return arc;
};
arc.outerRadius = function(v) {
if (!arguments.length) return outerRadius;
outerRadius = d3.functor(v);
outerRadius = d3_functor(v);
return arc;
};
arc.startAngle = function(v) {
if (!arguments.length) return startAngle;
startAngle = d3.functor(v);
startAngle = d3_functor(v);
return arc;
};
arc.endAngle = function(v) {
if (!arguments.length) return endAngle;
endAngle = d3.functor(v);
endAngle = d3_functor(v);
return arc;
};
@ -3239,36 +3250,66 @@ function d3_svg_arcEndAngle(d) {
function d3_svg_line(projection) {
var x = d3_svg_lineX,
y = d3_svg_lineY,
defined = d3_true,
interpolate = d3_svg_lineInterpolatorDefault,
interpolator = d3_svg_lineInterpolators.get(interpolate),
interpolator = d3_svg_lineLinear,
tension = .7;
function line(d) {
return d.length < 1 ? null : "M" + interpolator(projection(d3_svg_linePoints(this, d, x, y)), tension);
function line(data) {
var segments = [],
points = [],
i = -1,
n = data.length,
d,
fx = d3_functor(x),
fy = d3_functor(y);
function segment() {
segments.push("M", interpolator(projection(points), tension));
}
while (++i < n) {
if (defined.call(this, d = data[i], i)) {
points.push([+fx.call(this, d, i), +fy.call(this, d, i)]);
} else if (points.length) {
segment();
points = [];
}
}
if (points.length) segment();
return segments.length ? segments.join("") : null;
}
line.x = function(v) {
line.x = function(_) {
if (!arguments.length) return x;
x = v;
x = _;
return line;
};
line.y = function(v) {
line.y = function(_) {
if (!arguments.length) return y;
y = v;
y = _;
return line;
};
line.interpolate = function(v) {
line.defined = function(_) {
if (!arguments.length) return defined;
defined = _;
return line;
};
line.interpolate = function(_) {
if (!arguments.length) return interpolate;
if (!d3_svg_lineInterpolators.has(v += "")) v = d3_svg_lineInterpolatorDefault;
interpolator = d3_svg_lineInterpolators.get(interpolate = v);
if (!d3_svg_lineInterpolators.has(_ += "")) _ = d3_svg_lineInterpolatorDefault;
interpolator = d3_svg_lineInterpolators.get(interpolate = _);
return line;
};
line.tension = function(v) {
line.tension = function(_) {
if (!arguments.length) return tension;
tension = v;
tension = _;
return line;
};
@ -3276,35 +3317,9 @@ function d3_svg_line(projection) {
}
d3.svg.line = function() {
return d3_svg_line(Object);
return d3_svg_line(d3_identity);
};
// Converts the specified array of data into an array of points
// (x-y tuples), by evaluating the specified `x` and `y` functions on each
// data point. The `this` context of the evaluated functions is the specified
// "self" object; each function is passed the current datum and index.
function d3_svg_linePoints(self, d, x, y) {
var points = [],
i = -1,
n = d.length,
fx = typeof x === "function",
fy = typeof y === "function",
value;
if (fx && fy) {
while (++i < n) points.push([
x.call(self, value = d[i], i),
y.call(self, value, i)
]);
} else if (fx) {
while (++i < n) points.push([x.call(self, d[i], i), y]);
} else if (fy) {
while (++i < n) points.push([x, y.call(self, d[i], i)]);
} else {
while (++i < n) points.push([x, y]);
}
return points;
}
// The default `x` property, which references d[0].
function d3_svg_lineX(d) {
return d[0];
@ -3640,8 +3655,7 @@ function d3_svg_lineMonotoneTangents(points) {
// not monotonic, it's possible that the slope will be infinite, so we protect
// against NaN by setting the coordinate to zero.
i = -1; while (++i <= j) {
s = (points[Math.min(j, i + 1)][0] - points[Math.max(0, i - 1)][0])
/ (6 * (1 + m[i] * m[i]));
s = (points[Math.min(j, i + 1)][0] - points[Math.max(0, i - 1)][0]) / (6 * (1 + m[i] * m[i]));
tangents.push([s || 0, m[i] * s || 0]);
}
@ -3651,8 +3665,7 @@ function d3_svg_lineMonotoneTangents(points) {
function d3_svg_lineMonotone(points) {
return points.length < 3
? d3_svg_lineLinear(points)
: points[0] +
d3_svg_lineHermite(points, d3_svg_lineMonotoneTangents(points));
: points[0] + d3_svg_lineHermite(points, d3_svg_lineMonotoneTangents(points));
}
d3.svg.line.radial = function() {
var line = d3_svg_line(d3_svg_lineRadial);
@ -3681,71 +3694,107 @@ function d3_svg_area(projection) {
x1 = d3_svg_lineX,
y0 = 0,
y1 = d3_svg_lineY,
interpolate,
i0,
i1,
defined = d3_true,
interpolate = d3_svg_lineInterpolatorDefault,
i0 = d3_svg_lineLinear,
i1 = d3_svg_lineLinear,
L = "L",
tension = .7;
function area(d) {
if (d.length < 1) return null;
var points0 = d3_svg_linePoints(this, d, x0, y0),
points1 = d3_svg_linePoints(this, d, x0 === x1 ? d3_svg_areaX(points0) : x1, y0 === y1 ? d3_svg_areaY(points0) : y1);
return "M" + i0(projection(points1), tension)
+ "L" + i1(projection(points0.reverse()), tension)
+ "Z";
function area(data) {
var segments = [],
points0 = [],
points1 = [],
i = -1,
n = data.length,
d,
fx0 = d3_functor(x0),
fy0 = d3_functor(y0),
fx1 = x0 === x1 ? function() { return x; } : d3_functor(x1),
fy1 = y0 === y1 ? function() { return y; } : d3_functor(y1),
x,
y;
function segment() {
segments.push("M", i0(projection(points1), tension),
L, i1(projection(points0.reverse()), tension),
"Z");
}
while (++i < n) {
if (defined.call(this, d = data[i], i)) {
points0.push([x = +fx0.call(this, d, i), y = +fy0.call(this, d, i)]);
points1.push([+fx1.call(this, d, i), +fy1.call(this, d, i)]);
} else if (points0.length) {
segment();
points0 = [];
points1 = [];
}
}
if (points0.length) segment();
return segments.length ? segments.join("") : null;
}
area.x = function(x) {
area.x = function(_) {
if (!arguments.length) return x1;
x0 = x1 = x;
x0 = x1 = _;
return area;
};
area.x0 = function(x) {
area.x0 = function(_) {
if (!arguments.length) return x0;
x0 = x;
x0 = _;
return area;
};
area.x1 = function(x) {
area.x1 = function(_) {
if (!arguments.length) return x1;
x1 = x;
x1 = _;
return area;
};
area.y = function(y) {
area.y = function(_) {
if (!arguments.length) return y1;
y0 = y1 = y;
y0 = y1 = _;
return area;
};
area.y0 = function(y) {
area.y0 = function(_) {
if (!arguments.length) return y0;
y0 = y;
y0 = _;
return area;
};
area.y1 = function(y) {
area.y1 = function(_) {
if (!arguments.length) return y1;
y1 = y;
y1 = _;
return area;
};
area.defined = function(_) {
if (!arguments.length) return defined;
defined = _;
return area;
};
area.interpolate = function(x) {
area.interpolate = function(_) {
if (!arguments.length) return interpolate;
if (!d3_svg_lineInterpolators.has(x += "")) x = d3_svg_lineInterpolatorDefault;
i0 = d3_svg_lineInterpolators.get(interpolate = x);
if (!d3_svg_lineInterpolators.has(_ += "")) _ = d3_svg_lineInterpolatorDefault;
i0 = d3_svg_lineInterpolators.get(interpolate = _);
i1 = i0.reverse || i0;
L = /-closed$/.test(_) ? "M" : "L";
return area;
};
area.tension = function(x) {
area.tension = function(_) {
if (!arguments.length) return tension;
tension = x;
tension = _;
return area;
};
return area.interpolate("linear");
return area;
}
d3_svg_lineStepBefore.reverse = d3_svg_lineStepAfter;
@ -3754,18 +3803,6 @@ d3_svg_lineStepAfter.reverse = d3_svg_lineStepBefore;
d3.svg.area = function() {
return d3_svg_area(Object);
};
function d3_svg_areaX(points) {
return function(d, i) {
return points[i][0];
};
}
function d3_svg_areaY(points) {
return function(d, i) {
return points[i][1];
};
}
d3.svg.area.radial = function() {
var area = d3_svg_area(d3_svg_lineRadial);
area.radius = area.x, delete area.x;
@ -3825,31 +3862,31 @@ d3.svg.chord = function() {
chord.radius = function(v) {
if (!arguments.length) return radius;
radius = d3.functor(v);
radius = d3_functor(v);
return chord;
};
chord.source = function(v) {
if (!arguments.length) return source;
source = d3.functor(v);
source = d3_functor(v);
return chord;
};
chord.target = function(v) {
if (!arguments.length) return target;
target = d3.functor(v);
target = d3_functor(v);
return chord;
};
chord.startAngle = function(v) {
if (!arguments.length) return startAngle;
startAngle = d3.functor(v);
startAngle = d3_functor(v);
return chord;
};
chord.endAngle = function(v) {
if (!arguments.length) return endAngle;
endAngle = d3.functor(v);
endAngle = d3_functor(v);
return chord;
};
@ -3891,13 +3928,13 @@ d3.svg.diagonal = function() {
diagonal.source = function(x) {
if (!arguments.length) return source;
source = d3.functor(x);
source = d3_functor(x);
return diagonal;
};
diagonal.target = function(x) {
if (!arguments.length) return target;
target = d3.functor(x);
target = d3_functor(x);
return diagonal;
};
@ -3949,14 +3986,14 @@ d3.svg.symbol = function() {
symbol.type = function(x) {
if (!arguments.length) return type;
type = d3.functor(x);
type = d3_functor(x);
return symbol;
};
// size of symbol in square pixels
symbol.size = function(x) {
if (!arguments.length) return size;
size = d3.functor(x);
size = d3_functor(x);
return symbol;
};
@ -4633,6 +4670,7 @@ d3.behavior.drag = function() {
offset = [0, 0];
}
d3_eventCancel();
event_({type: "dragstart"});
function point() {
@ -4787,7 +4825,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);
if (moved && d3.event.target === eventTarget) w.on("click.zoom", click, true);
}
function click() {
@ -5011,12 +5049,12 @@ d3.layout.chord = function() {
value: v
};
}
groups.push({
groups[di] = {
index: di,
startAngle: x0,
endAngle: x,
value: (x - x0) / k
});
};
x += padding;
}
@ -5229,7 +5267,7 @@ d3.layout.force = function() {
force.linkDistance = function(x) {
if (!arguments.length) return linkDistance;
linkDistance = d3.functor(x);
linkDistance = d3_functor(x);
return force;
};
@ -5238,7 +5276,7 @@ d3.layout.force = function() {
force.linkStrength = function(x) {
if (!arguments.length) return linkStrength;
linkStrength = d3.functor(x);
linkStrength = d3_functor(x);
return force;
};
@ -5366,7 +5404,7 @@ d3.layout.force = function() {
// use `node.call(force.drag)` to make nodes draggable
force.drag = function() {
if (!drag) drag = d3.behavior.drag()
.origin(Object)
.origin(d3_identity)
.on("dragstart", dragstart)
.on("drag", d3_layout_forceDrag)
.on("dragend", d3_layout_forceDragEnd);
@ -5526,6 +5564,7 @@ d3.layout.pie = function() {
// They are stored in the original data's order.
var arcs = [];
index.forEach(function(i) {
var d;
arcs[i] = {
data: data[i],
value: d = values[i],
@ -5589,7 +5628,7 @@ d3.layout.pie = function() {
var d3_layout_pieSortByValue = {};
// data is two-dimensional array of x,y; we populate y0
d3.layout.stack = function() {
var values = Object,
var values = d3_identity,
order = d3_layout_stackOrderDefault,
offset = d3_layout_stackOffsetZero,
out = d3_layout_stackOut,
@ -5854,12 +5893,14 @@ d3.layout.histogram = function() {
}
// Fill the bins, ignoring values outside the range.
i = -1; while(++i < n) {
x = values[i];
if ((x >= range[0]) && (x <= range[1])) {
bin = bins[d3.bisect(thresholds, x, 1, m) - 1];
bin.y += k;
bin.push(data[i]);
if (m > 0) {
i = -1; while(++i < n) {
x = values[i];
if ((x >= range[0]) && (x <= range[1])) {
bin = bins[d3.bisect(thresholds, x, 1, m) - 1];
bin.y += k;
bin.push(data[i]);
}
}
}
@ -5882,7 +5923,7 @@ d3.layout.histogram = function() {
// values.
histogram.range = function(x) {
if (!arguments.length) return ranger;
ranger = d3.functor(x);
ranger = d3_functor(x);
return histogram;
};
@ -5899,7 +5940,7 @@ d3.layout.histogram = function() {
if (!arguments.length) return binner;
binner = typeof x === "number"
? function(range) { return d3_layout_histogramBinFixed(range, x); }
: d3.functor(x);
: d3_functor(x);
return histogram;
};
@ -5947,7 +5988,8 @@ d3.layout.hierarchy = function() {
n,
c = node.children = [],
v = 0,
j = depth + 1;
j = depth + 1,
d;
while (++i < n) {
d = recurse(childs[i], j, nodes);
d.parent = node;
@ -7585,7 +7627,7 @@ d3.geo.circle = function() {
var origin = [0, 0],
degrees = 90 - 1e-2,
radians = degrees * d3_geo_radians,
arc = d3.geo.greatArc().target(Object);
arc = d3.geo.greatArc().target(d3_identity);
function circle() {
// TODO render a circle as a Polygon
@ -7603,7 +7645,7 @@ d3.geo.circle = function() {
var clipType = d3_geo_type({
FeatureCollection: function(o) {
var features = o.features.map(clipType).filter(Object);
var features = o.features.map(clipType).filter(d3_identity);
return features && (o = Object.create(o), o.features = features, o);
},
@ -7645,7 +7687,7 @@ d3.geo.circle = function() {
},
GeometryCollection: function(o) {
var geometries = o.geometries.map(clipType).filter(Object);
var geometries = o.geometries.map(clipType).filter(d3_identity);
return geometries.length && (o = Object.create(o), o.geometries = geometries, o);
}
@ -8809,7 +8851,7 @@ function d3_time_parseWeekday(date, string, i) {
}
var d3_time_weekdayAbbrevRe = /^(?:sun|mon|tue|wed|thu|fri|sat)/i,
d3_time_weekdayRe = /^(?:Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday)/i;
d3_time_weekdayRe = /^(?:Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday)/i,
d3_time_weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
function d3_time_parseMonthAbbrev(date, string, i) {

8
lib/d3.v2.min.js vendored

File diff suppressed because one or more lines are too long

@ -204,7 +204,7 @@ nv.models.multiBarWithLegend = function() {
chart.xAxis = xAxis;
chart.yAxis = yAxis;
d3.rebind(chart, multibar, 'x', 'y', 'xDomain', 'yDomain', 'forceX', 'forceY', 'clipEdge', 'id');
d3.rebind(chart, multibar, 'x', 'y', 'xDomain', 'yDomain', 'forceX', 'forceY', 'clipEdge', 'id', 'stacked');
chart.margin = function(_) {

Loading…
Cancel
Save