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},
color = d3.scale.category20().range(),
color = nv.utils.getColor(),
width = null,
height = null,
showLegend = true,
@ -141,7 +141,7 @@ nv.models.cumulativeLineChart = function() {
.width(availableWidth)
.height(availableHeight)
.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 }));
@ -299,8 +299,8 @@ nv.models.cumulativeLineChart = function() {
chart.color = function(_) {
if (!arguments.length) return color;
color = _;
legend.color(_);
color = nv.utils.getColor(_);
legend.color(color);
return chart;
};

@ -14,7 +14,7 @@ nv.models.discreteBar = function() {
getX = function(d) { return d.x },
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
color = d3.scale.category20().range(),
color = nv.utils.defaultColor(),
showValues = false,
valueFormat = d3.format(',.2f'),
xDomain, yDomain;
@ -156,8 +156,8 @@ nv.models.discreteBar = function() {
barsEnter.append('rect')
.attr('height', 0)
.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('stroke', function(d,i){ return d.color || color[i % color.length] });
.style('fill', function(d,i){ return d.color || color(d, i) })
.style('stroke', function(d,i){ return d.color || color(d, i)});
if (showValues) {
barsEnter.append('text')
@ -267,7 +267,7 @@ nv.models.discreteBar = function() {
chart.color = function(_) {
if (!arguments.length) return color;
color = _;
color = nv.utils.getColor(_);
return chart;
};

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

@ -5,7 +5,7 @@ nv.models.distribution = function() {
size = 8,
axis = 'x', // 'x' or 'y'... horizontal or vertical
getData = function(d) { return d[axis] }, // defaults d.x or d.y
color = d3.scale.category20().range(),
color = nv.utils.defaultColor(),
domain;
var scale = d3.scale.linear(),
@ -40,7 +40,7 @@ nv.models.distribution = function() {
distWrap.enter().append('g')
distWrap
.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] });
var dist = distWrap.selectAll('line.dist' + axis)
@ -110,7 +110,7 @@ nv.models.distribution = function() {
chart.color = function(_) {
if (!arguments.length) return color;
color = _;
color = nv.utils.getColor(_);
return chart;
};

@ -9,7 +9,7 @@ nv.models.historicalBar = function() {
forceX = [],
forceY = [],
clipEdge = true,
color = d3.scale.category20().range(),
color = nv.utils.defaultColor(),
xDomain, yDomain;
var x = d3.scale.linear(),
@ -91,7 +91,7 @@ nv.models.historicalBar = function() {
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('fill', function(d,i) { return color[0]; })
.attr('fill', function(d,i) { return color(d, i); })
.attr('x', 0 )
.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)) })
@ -235,7 +235,7 @@ nv.models.historicalBar = function() {
chart.color = function(_) {
if (!arguments.length) return color;
color = _;
color = nv.utils.getColor(_);
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
width = 960,
height = 500,
color = d3.scale.category20().range(),
color = nv.utils.defaultColor(),
id = Math.floor(Math.random() * 10000),
header = true,
noResultsText = 'No Results found.'
@ -236,8 +236,8 @@ nv.models.indentedTree = function() {
chart.color = function(_) {
if (!arguments.length) return color;
color = _;
scatter.color(_);
color = nv.utils.getColor(_);
scatter.color(color);
return chart;
};

@ -8,7 +8,7 @@ nv.models.line = function() {
var margin = {top: 0, right: 0, bottom: 0, left: 0},
width = 960,
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
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
@ -94,8 +94,8 @@ nv.models.line = function() {
groups
.attr('class', function(d,i) { return 'group series-' + i })
.classed('hover', function(d) { return d.hover })
.style('fill', function(d,i){ return color[i % color.length] })
.style('stroke', function(d,i){ return color[i % color.length] });
.style('fill', function(d,i){ return color(d, i) })
.style('stroke', function(d,i){ return color(d, i)});
d3.transition(groups)
.style('stroke-opacity', 1)
.style('fill-opacity', .5);
@ -230,8 +230,8 @@ nv.models.line = function() {
chart.color = function(_) {
if (!arguments.length) return color;
color = _;
scatter.color(_);
color = nv.utils.getColor(_);
scatter.color(color);
return chart;
};

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

@ -5,7 +5,7 @@ nv.models.linePlusBarChart = function() {
height = null,
getX = function(d) { return d.x },
getY = function(d) { return d.y },
color = d3.scale.category20().range(),
color = nv.utils.defaultColor(),
showLegend = true,
tooltips = true,
tooltip = function(key, x, y, e, graph) {
@ -131,14 +131,14 @@ nv.models.linePlusBarChart = function() {
.width(availableWidth)
.height(availableHeight)
.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 }))
bars
.width(availableWidth)
.height(availableHeight)
.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 }))
@ -287,8 +287,8 @@ nv.models.linePlusBarChart = function() {
chart.color = function(_) {
if (!arguments.length) return color;
color = _;
legend.color(_);
color = nv.utils.getColor(_);
legend.color(color);
return chart;
};

@ -4,7 +4,7 @@ nv.models.line = function() {
var margin = {top: 0, right: 0, bottom: 0, left: 0},
width = 960,
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
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
@ -85,8 +85,8 @@ nv.models.line = function() {
groups
.attr('class', function(d,i) { return 'group series-' + i })
.classed('hover', function(d) { return d.hover })
.style('fill', function(d,i){ return color[i % color.length] })
.style('stroke', function(d,i){ return color[i % color.length] })
.style('fill', function(d,i){ return color(d, i) })
.style('stroke', function(d,i){ return color(d, i) })
d3.transition(groups)
.style('stroke-opacity', 1)
.style('fill-opacity', .5)
@ -170,8 +170,8 @@ nv.models.line = function() {
chart.color = function(_) {
if (!arguments.length) return color;
color = _;
scatter.color(_);
color = nv.utils.getColor(_);
scatter.color(color);
return chart;
};

@ -1,7 +1,7 @@
nv.models.lineChart = function() {
var margin = {top: 30, right: 20, bottom: 50, left: 60},
color = d3.scale.category20().range(),
color = nv.utils.defaultColor(),
width = null,
height = null,
showLegend = true,
@ -109,7 +109,7 @@ nv.models.lineChart = function() {
.width(availableWidth)
.height(availableHeight)
.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 }));
@ -269,8 +269,8 @@ nv.models.lineChart = function() {
chart.color = function(_) {
if (!arguments.length) return color;
color = _;
legend.color(_);
color = nv.utils.getColor(_);
legend.color(color);
return chart;
};

@ -2,7 +2,7 @@
nv.models.lineWithFocusChart = function() {
var margin = {top: 30, right: 20, bottom: 50, left: 60},
margin2 = {top: 0, right: 20, bottom: 20, left: 60},
color = d3.scale.category20().range(),
color = nv.utils.defaultColor(),
width = null,
height = null,
height2 = 100,
@ -98,7 +98,7 @@ nv.models.lineWithFocusChart = function() {
.width(availableWidth)
.height(availableHeight)
.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 }));
lines2
@ -108,7 +108,7 @@ nv.models.lineWithFocusChart = function() {
.x(lines.x())
.y(lines.y())
.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 }));
@ -316,8 +316,8 @@ nv.models.lineWithFocusChart = function() {
chart.color = function(_) {
if (!arguments.length) return color;
color = _;
legend.color(_);
color =nv.utils.getColor(_);
legend.color(color);
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
clipEdge = true,
stacked = false,
color = d3.scale.category20().range(),
color = nv.utils.defaultColor(),
delay = 1200,
xDomain, yDomain;
@ -132,8 +132,8 @@ nv.models.multiBar = function() {
groups
.attr('class', function(d,i) { return 'group series-' + i })
.classed('hover', function(d) { return d.hover })
.style('fill', function(d,i){ return color[i % color.length] })
.style('stroke', function(d,i){ return color[i % color.length] });
.style('fill', function(d,i){ return color(d, i) })
.style('stroke', function(d,i){ return color(d, i) });
d3.transition(groups)
.style('stroke-opacity', 1)
.style('fill-opacity', .75);
@ -334,7 +334,7 @@ nv.models.multiBar = function() {
chart.color = function(_) {
if (!arguments.length) return color;
color = _;
color = nv.utils.getColor(_);
return chart;
};

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

@ -9,7 +9,7 @@ nv.models.multiBarHorizontal = function() {
getX = function(d) { return d.x },
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
color = d3.scale.category20().range(),
color = nv.utils.defaultColor(),
stacked = false,
showValues = false,
valuePadding = 60,
@ -90,8 +90,8 @@ nv.models.multiBarHorizontal = function() {
groups
.attr('class', function(d,i) { return 'group series-' + i })
.classed('hover', function(d) { return d.hover })
.style('fill', function(d,i){ return color[i % color.length] })
.style('stroke', function(d,i){ return color[i % color.length] });
.style('fill', function(d,i){ return color(d, i) })
.style('stroke', function(d,i){ return color(d, i) });
d3.transition(groups)
.style('stroke-opacity', 1)
.style('fill-opacity', .75);
@ -336,7 +336,7 @@ nv.models.multiBarHorizontal = function() {
chart.color = function(_) {
if (!arguments.length) return color;
color = _;
color = nv.utils.getColor(_);
return chart;
};

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

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

@ -7,7 +7,7 @@ nv.models.pie = function() {
getX = function(d) { return d.x },
getY = function(d) { return d.y },
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'),
showLabels = true,
labelThreshold = .02, //if slice percentage is under this, don't show label
@ -108,8 +108,8 @@ nv.models.pie = function() {
});
slices
.attr('fill', function(d,i) { return color[i]; })
.attr('stroke', function(d,i) { return color[i]; });
.attr('fill', function(d,i) { return color(d, i); })
.attr('stroke', function(d,i) { return color(d, i); });
var paths = ae.append('svg:path')
.each(function(d) { this._current = d; });
@ -234,7 +234,7 @@ nv.models.pie = function() {
chart.color = function(_) {
if (!arguments.length) return color;
color = _;
color = nv.utils.getColor(_);
return chart;
};

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

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

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

@ -6,7 +6,7 @@ nv.models.sparkline = function() {
animate = true,
getX = function(d) { return d.x },
getY = function(d) { return d.y },
color = d3.scale.category20().range(),
color = nv.utils.defaultColor(),
xDomain, yDomain;
var x = d3.scale.linear(),
@ -32,7 +32,7 @@ nv.models.sparkline = function() {
//gEnter.append('g').attr('class', 'sparkline')
gEnter
.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)

@ -6,7 +6,7 @@ nv.models.sparklinePlus = function() {
animate = true,
getX = function(d) { return d.x },
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
xTickFormat = d3.format(',r'),
yTickFormat = d3.format(',.2f');
@ -34,7 +34,7 @@ nv.models.sparklinePlus = function() {
//var gEnter = svg.enter().append('svg').append('g');
var sparklineWrap = gEnter.append('g').attr('class', 'nvd3 sparklineplus')
.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
.xDomain(x.domain())

Loading…
Cancel
Save