update models to use new colors

master-patched
Jyry Suvilehto 12 years ago
parent 3c9cb18afe
commit ca6e2c589b

@ -6,7 +6,7 @@ nv.models.cumulativeLineChart = function() {
//------------------------------------------------------------ //------------------------------------------------------------
var margin = {top: 30, right: 20, bottom: 50, left: 60}, var margin = {top: 30, right: 20, bottom: 50, left: 60},
color = d3.scale.category20().range(), color = nv.utils.getColor(),
width = null, width = null,
height = null, height = null,
showLegend = true, showLegend = true,
@ -141,7 +141,7 @@ nv.models.cumulativeLineChart = function() {
.width(availableWidth) .width(availableWidth)
.height(availableHeight) .height(availableHeight)
.color(data.map(function(d,i) { .color(data.map(function(d,i) {
return d.color || color[i % color.length]; return d.color || color(d, i);
}).filter(function(d,i) { return !data[i].disabled })); }).filter(function(d,i) { return !data[i].disabled }));
@ -299,8 +299,8 @@ nv.models.cumulativeLineChart = function() {
chart.color = function(_) { chart.color = function(_) {
if (!arguments.length) return color; if (!arguments.length) return color;
color = _; color = nv.utils.getColor(_);
legend.color(_); legend.color(color);
return chart; return chart;
}; };

@ -14,7 +14,7 @@ nv.models.discreteBar = function() {
getX = function(d) { return d.x }, getX = function(d) { return d.x },
getY = function(d) { return d.y }, getY = function(d) { return d.y },
forceY = [0], // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove forceY = [0], // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove
color = d3.scale.category20().range(), color = nv.utils.defaultColor(),
showValues = false, showValues = false,
valueFormat = d3.format(',.2f'), valueFormat = d3.format(',.2f'),
xDomain, yDomain; xDomain, yDomain;
@ -156,8 +156,8 @@ nv.models.discreteBar = function() {
barsEnter.append('rect') barsEnter.append('rect')
.attr('height', 0) .attr('height', 0)
.attr('width', x.rangeBand() / data.length ) .attr('width', x.rangeBand() / data.length )
.style('fill', function(d,i){ return d.color || color[i % color.length] }) //this is a 'hack' to allow multiple colors in a single series... will need to rethink this methodology .style('fill', function(d,i){ return d.color || color(d, i) })
.style('stroke', function(d,i){ return d.color || color[i % color.length] }); .style('stroke', function(d,i){ return d.color || color(d, i)});
if (showValues) { if (showValues) {
barsEnter.append('text') barsEnter.append('text')
@ -267,7 +267,7 @@ nv.models.discreteBar = function() {
chart.color = function(_) { chart.color = function(_) {
if (!arguments.length) return color; if (!arguments.length) return color;
color = _; color = nv.utils.getColor(_);
return chart; return chart;
}; };

@ -3,7 +3,7 @@ nv.models.discreteBarChart = function() {
var margin = {top: 10, right: 10, bottom: 50, left: 60}, var margin = {top: 10, right: 10, bottom: 50, left: 60},
width = null, width = null,
height = null, height = null,
color = d3.scale.category20().range(), color = nv.utils.getColor(), //a function that gets color for a datum
staggerLabels = false, staggerLabels = false,
rotateLabels = 0, rotateLabels = 0,
tooltips = true, tooltips = true,
@ -176,8 +176,8 @@ nv.models.discreteBarChart = function() {
chart.color = function(_) { chart.color = function(_) {
if (!arguments.length) return color; if (!arguments.length) return color;
color = _; color = nv.utils.getColor(_);
discretebar.color(_); discretebar.color(color;
return chart; return chart;
}; };

@ -5,7 +5,7 @@ nv.models.distribution = function() {
size = 8, size = 8,
axis = 'x', // 'x' or 'y'... horizontal or vertical axis = 'x', // 'x' or 'y'... horizontal or vertical
getData = function(d) { return d[axis] }, // defaults d.x or d.y getData = function(d) { return d[axis] }, // defaults d.x or d.y
color = d3.scale.category20().range(), color = nv.utils.defaultColor(),
domain; domain;
var scale = d3.scale.linear(), var scale = d3.scale.linear(),
@ -40,7 +40,7 @@ nv.models.distribution = function() {
distWrap.enter().append('g') distWrap.enter().append('g')
distWrap distWrap
.attr('class', function(d,i) { return 'dist series-' + i }) .attr('class', function(d,i) { return 'dist series-' + i })
.style('stroke', function(d,i) { return color[i % color.length] }); .style('stroke', function(d,i) { return color(d, i) });
//.style('stroke', function(d,i) { return color.filter(function(d,i) { return data[i] && !data[i].disabled })[i % color.length] }); //.style('stroke', function(d,i) { return color.filter(function(d,i) { return data[i] && !data[i].disabled })[i % color.length] });
var dist = distWrap.selectAll('line.dist' + axis) var dist = distWrap.selectAll('line.dist' + axis)
@ -110,7 +110,7 @@ nv.models.distribution = function() {
chart.color = function(_) { chart.color = function(_) {
if (!arguments.length) return color; if (!arguments.length) return color;
color = _; color = nv.utils.getColor(_);
return chart; return chart;
}; };

@ -9,7 +9,7 @@ nv.models.historicalBar = function() {
forceX = [], forceX = [],
forceY = [], forceY = [],
clipEdge = true, clipEdge = true,
color = d3.scale.category20().range(), color = nv.utils.defaultColor(),
xDomain, yDomain; xDomain, yDomain;
var x = d3.scale.linear(), var x = d3.scale.linear(),
@ -91,7 +91,7 @@ nv.models.historicalBar = function() {
var barsEnter = bars.enter().append('svg:rect') var barsEnter = bars.enter().append('svg:rect')
.attr('class', function(d,i,j) { return (getY(d,i) < 0 ? 'bar negative' : 'bar positive') + ' bar-' + j + '-' + i }) .attr('class', function(d,i,j) { return (getY(d,i) < 0 ? 'bar negative' : 'bar positive') + ' bar-' + j + '-' + i })
.attr('fill', function(d,i) { return color[0]; }) .attr('fill', function(d,i) { return color(d, i); })
.attr('x', 0 ) .attr('x', 0 )
.attr('y', function(d,i) { return y(Math.max(0, getY(d,i))) }) .attr('y', function(d,i) { return y(Math.max(0, getY(d,i))) })
.attr('height', function(d,i) { return Math.abs(y(getY(d,i)) - y(0)) }) .attr('height', function(d,i) { return Math.abs(y(getY(d,i)) - y(0)) })
@ -235,7 +235,7 @@ nv.models.historicalBar = function() {
chart.color = function(_) { chart.color = function(_) {
if (!arguments.length) return color; if (!arguments.length) return color;
color = _; color = nv.utils.getColor(_);
return chart; return chart;
}; };

@ -5,7 +5,7 @@ nv.models.indentedTree = function() {
var margin = {top: 0, right: 0, bottom: 0, left: 0}, //TODO: implement, maybe as margin on the containing div var margin = {top: 0, right: 0, bottom: 0, left: 0}, //TODO: implement, maybe as margin on the containing div
width = 960, width = 960,
height = 500, height = 500,
color = d3.scale.category20().range(), color = nv.utils.defaultColor(),
id = Math.floor(Math.random() * 10000), id = Math.floor(Math.random() * 10000),
header = true, header = true,
noResultsText = 'No Results found.' noResultsText = 'No Results found.'
@ -236,8 +236,8 @@ nv.models.indentedTree = function() {
chart.color = function(_) { chart.color = function(_) {
if (!arguments.length) return color; if (!arguments.length) return color;
color = _; color = nv.utils.getColor(_);
scatter.color(_); scatter.color(color);
return chart; return chart;
}; };

@ -8,7 +8,7 @@ nv.models.line = function() {
var margin = {top: 0, right: 0, bottom: 0, left: 0}, var margin = {top: 0, right: 0, bottom: 0, left: 0},
width = 960, width = 960,
height = 500, height = 500,
color = d3.scale.category20().range(), // array of colors to be used in order color = nv.utils.defaultColor(), // a function that returns a color
id = Math.floor(Math.random() * 10000), //Create semi-unique ID incase user doesn't select one id = Math.floor(Math.random() * 10000), //Create semi-unique ID incase user doesn't select one
getX = function(d) { return d.x }, // accessor to get the x value from a data point getX = function(d) { return d.x }, // accessor to get the x value from a data point
getY = function(d) { return d.y }, // accessor to get the y value from a data point getY = function(d) { return d.y }, // accessor to get the y value from a data point
@ -94,8 +94,8 @@ nv.models.line = function() {
groups groups
.attr('class', function(d,i) { return 'group series-' + i }) .attr('class', function(d,i) { return 'group series-' + i })
.classed('hover', function(d) { return d.hover }) .classed('hover', function(d) { return d.hover })
.style('fill', function(d,i){ return color[i % color.length] }) .style('fill', function(d,i){ return color(d, i) })
.style('stroke', function(d,i){ return color[i % color.length] }); .style('stroke', function(d,i){ return color(d, i)});
d3.transition(groups) d3.transition(groups)
.style('stroke-opacity', 1) .style('stroke-opacity', 1)
.style('fill-opacity', .5); .style('fill-opacity', .5);
@ -230,8 +230,8 @@ nv.models.line = function() {
chart.color = function(_) { chart.color = function(_) {
if (!arguments.length) return color; if (!arguments.length) return color;
color = _; color = nv.utils.getColor(_);
scatter.color(_); scatter.color(color);
return chart; return chart;
}; };

@ -6,7 +6,7 @@ nv.models.lineChart = function() {
//------------------------------------------------------------ //------------------------------------------------------------
var margin = {top: 30, right: 20, bottom: 50, left: 60}, var margin = {top: 30, right: 20, bottom: 50, left: 60},
color = d3.scale.category20().range(), color = nv.utils.defaultColor(),
width = null, width = null,
height = null, height = null,
showLegend = true, showLegend = true,
@ -102,7 +102,7 @@ nv.models.lineChart = function() {
.width(availableWidth) .width(availableWidth)
.height(availableHeight) .height(availableHeight)
.color(data.map(function(d,i) { .color(data.map(function(d,i) {
return d.color || color[i % color.length]; return d.color || color(d, i);
}).filter(function(d,i) { return !data[i].disabled })); }).filter(function(d,i) { return !data[i].disabled }));
@ -233,8 +233,8 @@ nv.models.lineChart = function() {
chart.color = function(_) { chart.color = function(_) {
if (!arguments.length) return color; if (!arguments.length) return color;
color = _; color = nv.utils.getColor(_);
legend.color(_); legend.color(color);
return chart; return chart;
}; };

@ -5,7 +5,7 @@ nv.models.linePlusBarChart = function() {
height = null, height = null,
getX = function(d) { return d.x }, getX = function(d) { return d.x },
getY = function(d) { return d.y }, getY = function(d) { return d.y },
color = d3.scale.category20().range(), color = nv.utils.defaultColor(),
showLegend = true, showLegend = true,
tooltips = true, tooltips = true,
tooltip = function(key, x, y, e, graph) { tooltip = function(key, x, y, e, graph) {
@ -131,14 +131,14 @@ nv.models.linePlusBarChart = function() {
.width(availableWidth) .width(availableWidth)
.height(availableHeight) .height(availableHeight)
.color(data.map(function(d,i) { .color(data.map(function(d,i) {
return d.color || color[i % color.length]; return d.color || color(d, i);
}).filter(function(d,i) { return !data[i].disabled && !data[i].bar })) }).filter(function(d,i) { return !data[i].disabled && !data[i].bar }))
bars bars
.width(availableWidth) .width(availableWidth)
.height(availableHeight) .height(availableHeight)
.color(data.map(function(d,i) { .color(data.map(function(d,i) {
return d.color || color[i % color.length]; return d.color || color(d, i);
}).filter(function(d,i) { return !data[i].disabled && data[i].bar })) }).filter(function(d,i) { return !data[i].disabled && data[i].bar }))
@ -287,8 +287,8 @@ nv.models.linePlusBarChart = function() {
chart.color = function(_) { chart.color = function(_) {
if (!arguments.length) return color; if (!arguments.length) return color;
color = _; color = nv.utils.getColor(_);
legend.color(_); legend.color(color);
return chart; return chart;
}; };

@ -4,7 +4,7 @@ nv.models.line = function() {
var margin = {top: 0, right: 0, bottom: 0, left: 0}, var margin = {top: 0, right: 0, bottom: 0, left: 0},
width = 960, width = 960,
height = 500, height = 500,
color = d3.scale.category20().range(), // array of colors to be used in order color = nv.utils.defaultColor(), // function that returns colors
id = Math.floor(Math.random() * 10000), //Create semi-unique ID incase user doesn't select one id = Math.floor(Math.random() * 10000), //Create semi-unique ID incase user doesn't select one
getX = function(d) { return d.x }, // accessor to get the x value from a data point getX = function(d) { return d.x }, // accessor to get the x value from a data point
getY = function(d) { return d.y }, // accessor to get the y value from a data point getY = function(d) { return d.y }, // accessor to get the y value from a data point
@ -85,8 +85,8 @@ nv.models.line = function() {
groups groups
.attr('class', function(d,i) { return 'group series-' + i }) .attr('class', function(d,i) { return 'group series-' + i })
.classed('hover', function(d) { return d.hover }) .classed('hover', function(d) { return d.hover })
.style('fill', function(d,i){ return color[i % color.length] }) .style('fill', function(d,i){ return color(d, i) })
.style('stroke', function(d,i){ return color[i % color.length] }) .style('stroke', function(d,i){ return color(d, i) })
d3.transition(groups) d3.transition(groups)
.style('stroke-opacity', 1) .style('stroke-opacity', 1)
.style('fill-opacity', .5) .style('fill-opacity', .5)
@ -170,8 +170,8 @@ nv.models.line = function() {
chart.color = function(_) { chart.color = function(_) {
if (!arguments.length) return color; if (!arguments.length) return color;
color = _; color = nv.utils.getColor(_);
scatter.color(_); scatter.color(color);
return chart; return chart;
}; };

@ -1,7 +1,7 @@
nv.models.lineChart = function() { nv.models.lineChart = function() {
var margin = {top: 30, right: 20, bottom: 50, left: 60}, var margin = {top: 30, right: 20, bottom: 50, left: 60},
color = d3.scale.category20().range(), color = nv.utils.defaultColor(),
width = null, width = null,
height = null, height = null,
showLegend = true, showLegend = true,
@ -109,7 +109,7 @@ nv.models.lineChart = function() {
.width(availableWidth) .width(availableWidth)
.height(availableHeight) .height(availableHeight)
.color(data.map(function(d,i) { .color(data.map(function(d,i) {
return d.color || color[i % color.length]; return d.color || color(d, i);
}).filter(function(d,i) { return !data[i].disabled })); }).filter(function(d,i) { return !data[i].disabled }));
@ -269,8 +269,8 @@ nv.models.lineChart = function() {
chart.color = function(_) { chart.color = function(_) {
if (!arguments.length) return color; if (!arguments.length) return color;
color = _; color = nv.utils.getColor(_);
legend.color(_); legend.color(color);
return chart; return chart;
}; };

@ -2,7 +2,7 @@
nv.models.lineWithFocusChart = function() { nv.models.lineWithFocusChart = function() {
var margin = {top: 30, right: 20, bottom: 50, left: 60}, var margin = {top: 30, right: 20, bottom: 50, left: 60},
margin2 = {top: 0, right: 20, bottom: 20, left: 60}, margin2 = {top: 0, right: 20, bottom: 20, left: 60},
color = d3.scale.category20().range(), color = nv.utils.defaultColor(),
width = null, width = null,
height = null, height = null,
height2 = 100, height2 = 100,
@ -98,7 +98,7 @@ nv.models.lineWithFocusChart = function() {
.width(availableWidth) .width(availableWidth)
.height(availableHeight) .height(availableHeight)
.color(data.map(function(d,i) { .color(data.map(function(d,i) {
return d.color || color[i % color.length]; return d.color || color(d, i);
}).filter(function(d,i) { return !data[i].disabled })); }).filter(function(d,i) { return !data[i].disabled }));
lines2 lines2
@ -108,7 +108,7 @@ nv.models.lineWithFocusChart = function() {
.x(lines.x()) .x(lines.x())
.y(lines.y()) .y(lines.y())
.color(data.map(function(d,i) { .color(data.map(function(d,i) {
return d.color || color[i % color.length]; return d.color || color(d, i);
}).filter(function(d,i) { return !data[i].disabled })); }).filter(function(d,i) { return !data[i].disabled }));
@ -316,8 +316,8 @@ nv.models.lineWithFocusChart = function() {
chart.color = function(_) { chart.color = function(_) {
if (!arguments.length) return color; if (!arguments.length) return color;
color = _; color =nv.utils.getColor(_);
legend.color(_); legend.color(color);
return chart; return chart;
}; };

@ -16,7 +16,7 @@ nv.models.multiBar = function() {
forceY = [0], // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove forceY = [0], // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove
clipEdge = true, clipEdge = true,
stacked = false, stacked = false,
color = d3.scale.category20().range(), color = nv.utils.defaultColor(),
delay = 1200, delay = 1200,
xDomain, yDomain; xDomain, yDomain;
@ -132,8 +132,8 @@ nv.models.multiBar = function() {
groups groups
.attr('class', function(d,i) { return 'group series-' + i }) .attr('class', function(d,i) { return 'group series-' + i })
.classed('hover', function(d) { return d.hover }) .classed('hover', function(d) { return d.hover })
.style('fill', function(d,i){ return color[i % color.length] }) .style('fill', function(d,i){ return color(d, i) })
.style('stroke', function(d,i){ return color[i % color.length] }); .style('stroke', function(d,i){ return color(d, i) });
d3.transition(groups) d3.transition(groups)
.style('stroke-opacity', 1) .style('stroke-opacity', 1)
.style('fill-opacity', .75); .style('fill-opacity', .75);
@ -334,7 +334,7 @@ nv.models.multiBar = function() {
chart.color = function(_) { chart.color = function(_) {
if (!arguments.length) return color; if (!arguments.length) return color;
color = _; color = nv.utils.getColor(_);
return chart; return chart;
}; };

@ -8,7 +8,7 @@ nv.models.multiBarChart = function() {
var margin = {top: 30, right: 20, bottom: 50, left: 60}, var margin = {top: 30, right: 20, bottom: 50, left: 60},
width = null, width = null,
height = null, height = null,
color = d3.scale.category20().range(), color = nv.utils.defaultColor(),
showControls = true, showControls = true,
showLegend = true, showLegend = true,
reduceXTicks = true, // if false a tick will show for every data point reduceXTicks = true, // if false a tick will show for every data point
@ -95,7 +95,7 @@ nv.models.multiBarChart = function() {
.width(availableWidth) .width(availableWidth)
.height(availableHeight) .height(availableHeight)
.color(data.map(function(d,i) { .color(data.map(function(d,i) {
return d.color || color[i % color.length]; return d.color || color(d, i);
}).filter(function(d,i) { return !data[i].disabled })) }).filter(function(d,i) { return !data[i].disabled }))
@ -259,8 +259,8 @@ nv.models.multiBarChart = function() {
chart.color = function(_) { chart.color = function(_) {
if (!arguments.length) return color; if (!arguments.length) return color;
color = _; color = nv.utils.getColor(_);
legend.color(_); legend.color(color);
return chart; return chart;
}; };

@ -9,7 +9,7 @@ nv.models.multiBarHorizontal = function() {
getX = function(d) { return d.x }, getX = function(d) { return d.x },
getY = function(d) { return d.y }, getY = function(d) { return d.y },
forceY = [0], // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove forceY = [0], // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove
color = d3.scale.category20().range(), color = nv.utils.defaultColor(),
stacked = false, stacked = false,
showValues = false, showValues = false,
valuePadding = 60, valuePadding = 60,
@ -90,8 +90,8 @@ nv.models.multiBarHorizontal = function() {
groups groups
.attr('class', function(d,i) { return 'group series-' + i }) .attr('class', function(d,i) { return 'group series-' + i })
.classed('hover', function(d) { return d.hover }) .classed('hover', function(d) { return d.hover })
.style('fill', function(d,i){ return color[i % color.length] }) .style('fill', function(d,i){ return color(d, i) })
.style('stroke', function(d,i){ return color[i % color.length] }); .style('stroke', function(d,i){ return color(d, i) });
d3.transition(groups) d3.transition(groups)
.style('stroke-opacity', 1) .style('stroke-opacity', 1)
.style('fill-opacity', .75); .style('fill-opacity', .75);
@ -336,7 +336,7 @@ nv.models.multiBarHorizontal = function() {
chart.color = function(_) { chart.color = function(_) {
if (!arguments.length) return color; if (!arguments.length) return color;
color = _; color = nv.utils.getColor(_);
return chart; return chart;
}; };

@ -3,7 +3,7 @@ nv.models.multiBarHorizontalChart = function() {
var margin = {top: 30, right: 20, bottom: 50, left: 60}, var margin = {top: 30, right: 20, bottom: 50, left: 60},
width = null, width = null,
height = null, height = null,
color = d3.scale.category20().range(), color = nv.utils.defaultColor(),
showControls = true, showControls = true,
showLegend = true, showLegend = true,
tooltips = true, tooltips = true,
@ -93,7 +93,7 @@ nv.models.multiBarHorizontalChart = function() {
.width(availableWidth) .width(availableWidth)
.height(availableHeight) .height(availableHeight)
.color(data.map(function(d,i) { .color(data.map(function(d,i) {
return d.color || color[i % color.length]; return d.color || color(d, i);
}).filter(function(d,i) { return !data[i].disabled })) }).filter(function(d,i) { return !data[i].disabled }))
@ -239,8 +239,8 @@ nv.models.multiBarHorizontalChart = function() {
chart.color = function(_) { chart.color = function(_) {
if (!arguments.length) return color; if (!arguments.length) return color;
color = _; color = nv.utils.getColor(_);
legend.color(_); legend.color(color);
return chart; return chart;
}; };

@ -13,7 +13,7 @@ nv.models.ohlcBar = function() {
forceX = [], forceX = [],
forceY = [], forceY = [],
clipEdge = true, clipEdge = true,
color = d3.scale.category20().range(), color = nv.utils.defaultColor(),
xDomain, yDomain; xDomain, yDomain;
var x = d3.scale.linear(), var x = d3.scale.linear(),
@ -278,7 +278,7 @@ nv.models.ohlcBar = function() {
chart.color = function(_) { chart.color = function(_) {
if (!arguments.length) return color; if (!arguments.length) return color;
color = _; color = nv.utils.getColor(_);
return chart; return chart;
}; };

@ -7,7 +7,7 @@ nv.models.pie = function() {
getX = function(d) { return d.x }, getX = function(d) { return d.x },
getY = function(d) { return d.y }, getY = function(d) { return d.y },
id = Math.floor(Math.random() * 10000), //Create semi-unique ID in case user doesn't select one id = Math.floor(Math.random() * 10000), //Create semi-unique ID in case user doesn't select one
color = d3.scale.category20().range(), color = nv.utils.defaultColor(),
valueFormat = d3.format(',.2f'), valueFormat = d3.format(',.2f'),
showLabels = true, showLabels = true,
labelThreshold = .02, //if slice percentage is under this, don't show label labelThreshold = .02, //if slice percentage is under this, don't show label
@ -108,8 +108,8 @@ nv.models.pie = function() {
}); });
slices slices
.attr('fill', function(d,i) { return color[i]; }) .attr('fill', function(d,i) { return color(d, i); })
.attr('stroke', function(d,i) { return color[i]; }); .attr('stroke', function(d,i) { return color(d, i); });
var paths = ae.append('svg:path') var paths = ae.append('svg:path')
.each(function(d) { this._current = d; }); .each(function(d) { this._current = d; });
@ -234,7 +234,7 @@ nv.models.pie = function() {
chart.color = function(_) { chart.color = function(_) {
if (!arguments.length) return color; if (!arguments.length) return color;
color = _; color = nv.utils.getColor(_);
return chart; return chart;
}; };

@ -4,7 +4,7 @@ nv.models.pieChart = function() {
width = null, width = null,
height = null, height = null,
showLegend = true, showLegend = true,
color = d3.scale.category20().range(), color = nv.utils.defaultColor(),
tooltips = true, tooltips = true,
tooltip = function(key, y, e, graph) { tooltip = function(key, y, e, graph) {
return '<h3>' + key + '</h3>' + return '<h3>' + key + '</h3>' +
@ -150,9 +150,9 @@ nv.models.pieChart = function() {
chart.color = function(_) { chart.color = function(_) {
if (!arguments.length) return color; if (!arguments.length) return color;
color = _; color = nv.utils.getColor(_);
legend.color(_); legend.color(color);
pie.color(_); pie.color(color);
return chart; return chart;
}; };

@ -8,7 +8,7 @@ nv.models.scatterChart = function() {
var margin = {top: 30, right: 20, bottom: 50, left: 60} var margin = {top: 30, right: 20, bottom: 50, left: 60}
, width = null , width = null
, height = null , height = null
, color = d3.scale.category20().range() , color = nv.utils.defaultColor()
//x = scatter.xScale(), //x = scatter.xScale(),
, x = d3.fisheye.scale(d3.scale.linear).distortion(0) , x = d3.fisheye.scale(d3.scale.linear).distortion(0)
//y = scatter.yScale(), //y = scatter.yScale(),
@ -152,7 +152,7 @@ nv.models.scatterChart = function() {
.width(availableWidth) .width(availableWidth)
.height(availableHeight) .height(availableHeight)
.color(data.map(function(d,i) { .color(data.map(function(d,i) {
return d.color || color[i % color.length]; return d.color || color(d, i);
}).filter(function(d,i) { return !data[i].disabled })) }).filter(function(d,i) { return !data[i].disabled }))
wrap.select('.scatterWrap') wrap.select('.scatterWrap')
@ -183,7 +183,7 @@ nv.models.scatterChart = function() {
.scale(x) .scale(x)
.width(availableWidth) .width(availableWidth)
.color(data.map(function(d,i) { .color(data.map(function(d,i) {
return d.color || color[i % color.length]; return d.color || color(d, i);
}).filter(function(d,i) { return !data[i].disabled })); }).filter(function(d,i) { return !data[i].disabled }));
gEnter.select('.distWrap').append('g') gEnter.select('.distWrap').append('g')
.attr('class', 'distributionX') .attr('class', 'distributionX')
@ -197,7 +197,7 @@ nv.models.scatterChart = function() {
.scale(y) .scale(y)
.width(availableHeight) .width(availableHeight)
.color(data.map(function(d,i) { .color(data.map(function(d,i) {
return d.color || color[i % color.length]; return d.color || color(d, i);
}).filter(function(d,i) { return !data[i].disabled })); }).filter(function(d,i) { return !data[i].disabled }));
gEnter.select('.distWrap').append('g') gEnter.select('.distWrap').append('g')
.attr('class', 'distributionY') .attr('class', 'distributionY')
@ -372,10 +372,10 @@ nv.models.scatterChart = function() {
chart.color = function(_) { chart.color = function(_) {
if (!arguments.length) return color; if (!arguments.length) return color;
color = _; color = nv.utils.getColor(_);
legend.color(_); legend.color(color);
distX.color(_); distX.color(color);
distY.color(_); distY.color(color);
return chart; return chart;
}; };

@ -3,7 +3,7 @@ nv.models.scatterFisheyeChart = function() {
var margin = {top: 30, right: 20, bottom: 50, left: 60}, var margin = {top: 30, right: 20, bottom: 50, left: 60},
width = null, width = null,
height = null, height = null,
color = d3.scale.category20().range(), color = nv.utils.defaultColor(),
showDistX = false, showDistX = false,
showDistY = false, showDistY = false,
showLegend = true, showLegend = true,
@ -115,7 +115,7 @@ nv.models.scatterFisheyeChart = function() {
.width(availableWidth) .width(availableWidth)
.height(availableHeight) .height(availableHeight)
.color(data.map(function(d,i) { .color(data.map(function(d,i) {
return d.color || color[i % color.length]; return d.color || color(d, i);
}).filter(function(d,i) { return !data[i].disabled })) }).filter(function(d,i) { return !data[i].disabled }))
@ -338,8 +338,8 @@ nv.models.scatterFisheyeChart = function() {
chart.color = function(_) { chart.color = function(_) {
if (!arguments.length) return color; if (!arguments.length) return color;
color = _; color = nv.utils.getColor(_);
legend.color(_); legend.color(color);
return chart; return chart;
}; };

@ -6,7 +6,7 @@ nv.models.sparkline = function() {
animate = true, animate = true,
getX = function(d) { return d.x }, getX = function(d) { return d.x },
getY = function(d) { return d.y }, getY = function(d) { return d.y },
color = d3.scale.category20().range(), color = nv.utils.defaultColor(),
xDomain, yDomain; xDomain, yDomain;
var x = d3.scale.linear(), var x = d3.scale.linear(),
@ -32,7 +32,7 @@ nv.models.sparkline = function() {
//gEnter.append('g').attr('class', 'sparkline') //gEnter.append('g').attr('class', 'sparkline')
gEnter gEnter
.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')') .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')')
.style('stroke', function(d,i) { return d.color || color[i * color.length] }); .style('stroke', function(d,i) { return d.color || color(d, i) });
/* /*
d3.select(this) d3.select(this)

@ -6,7 +6,7 @@ nv.models.sparklinePlus = function() {
animate = true, animate = true,
getX = function(d) { return d.x }, getX = function(d) { return d.x },
getY = function(d) { return d.y }, getY = function(d) { return d.y },
color = d3.scale.category20().range(), color = nv.utils.defaultColor(),
id = Math.floor(Math.random() * 100000), //Create semi-unique ID incase user doesn't selet one id = Math.floor(Math.random() * 100000), //Create semi-unique ID incase user doesn't selet one
xTickFormat = d3.format(',r'), xTickFormat = d3.format(',r'),
yTickFormat = d3.format(',.2f'); yTickFormat = d3.format(',.2f');
@ -34,7 +34,7 @@ nv.models.sparklinePlus = function() {
//var gEnter = svg.enter().append('svg').append('g'); //var gEnter = svg.enter().append('svg').append('g');
var sparklineWrap = gEnter.append('g').attr('class', 'nvd3 sparklineplus') var sparklineWrap = gEnter.append('g').attr('class', 'nvd3 sparklineplus')
.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')') .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')')
.style('stroke', function(d, i){ return d.color || color[i % color.length] }); .style('stroke', function(d, i){ return d.color || color(d, i) });
sparkline sparkline
.xDomain(x.domain()) .xDomain(x.domain())

Loading…
Cancel
Save