Discrete color chart color nvd3.js

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

I check the code and see that the color was received inline

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

I also track the discreteBarChart function

 color = nv.utils.getColor() 

What I do not understand and ask is what does color accept as a parameter?

+6
source share
2 answers

An array of colors is also required => ['#aec7e8', '#7b94b5', '#486192'] , something like this will work.

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

NVD3 inherits the default settings specified by d3 here

Hope this helps.

+9
source

If you want to use one color, you can return it from the parameter object, as shown below:

 var options={ .... colour:function(){ return '#ff0000'; }, ... .. } 
+2
source

Source: https://habr.com/ru/post/949676/


All Articles