Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Discrete Bar Chart colors nvd3.js

Tags:

nvd3.js

I am using nvd3.js discrete bar http://nvd3.org/ghpages/discreteBar.html

I am inspecting the code and seen that the color is been derived inline

style="fill: #ffbb78; stroke: #ffbb78;"

I also track on the discreteBarChart function

color = nv.utils.getColor()

What I don't realizing and asking is what does color takes as a parameter ?

like image 702
Petran Avatar asked Jul 17 '13 19:07

Petran


1 Answers

It requires and array of colors => ['#aec7e8', '#7b94b5', '#486192'] , something like this would work.

var chart = nv.models.discreteBarChart()
                   .... 
                   ....
                   .color(['#aec7e8', '#7b94b5', '#486192']);

NVD3 inherits the defaults colurs set by d3 here

Hope it helps.

like image 197
shabeer90 Avatar answered Oct 21 '22 16:10

shabeer90