Positive and negative stacked horizontal withunique colors per group

master-patched
Bob Monteverde 11 years ago
parent d4566d25e7
commit c2f5c49a8d

@ -363,8 +363,9 @@ nv.addGraph(function() {
.x(function(d) { return d.label })
.y(function(d) { return d.value })
.margin({top: 30, right: 20, bottom: 50, left: 175})
.showValues(true)
.tooltips(false)
//.showValues(true)
//.tooltips(false)
.barColor(d3.scale.category20().range())
.showControls(true);
chart.yAxis

@ -236,7 +236,12 @@ nv.models.multiBarHorizontal = function() {
.attr('class', function(d,i) { return getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive'})
if (barColor) {
bars.style('fill', barColor).style('stroke', barColor);
bars
.style('fill', function(d,i,j) { return d3.rgb(barColor(d,i)).darker(j).toString(); })
//.style('fill', function(d,i,j) { return d3.rgb(barColor(d,i)).darker( data.map(function(d,i) { return i }).filter(function(d,i){ return nv.log(data, !data[i].disabled) })[j] ).toString(); })
.style('stroke', function(d,i,j) { return d3.rgb(barColor(d,i)).darker(j).toString(); })
//.style('fill', barColor);
//.style('stroke', barColor);
}
if (stacked)

@ -135,6 +135,11 @@ nv.models.multiBarHorizontalChart = function() {
if (showLegend) {
legend.width(availableWidth / 2);
if (multibar.barColor())
data.forEach(function(series,i) {
series.color = d3.rgb('#bbb').darker(i * 2).toString();
})
g.select('.nv-legendWrap')
.datum(data)
.call(legend);
@ -330,7 +335,7 @@ nv.models.multiBarHorizontalChart = function() {
chart.xAxis = xAxis;
chart.yAxis = yAxis;
d3.rebind(chart, multibar, 'x', 'y', 'xDomain', 'yDomain', 'forceX', 'forceY', 'clipEdge', 'id', 'delay', 'showValues', 'valueFormat', 'stacked');
d3.rebind(chart, multibar, 'x', 'y', 'xDomain', 'yDomain', 'forceX', 'forceY', 'clipEdge', 'id', 'delay', 'showValues', 'valueFormat', 'stacked', 'barColor');
chart.margin = function(_) {
if (!arguments.length) return margin;

Loading…
Cancel
Save