NPashaP / Viz

BSD 3-Clause "New" or "Revised" License
106 stars 39 forks source link

Sample Code for Using Color Scales #15

Closed 100-km closed 6 years ago

100-km commented 7 years ago

Would you kindly provide sample code for using color scales with your biPartite layout.

For example, changing from:

var color = {Elite:"#3366CC", Grand:"#DC3912", Lite:"#FF9900", Medium:"#109618", Plus:"#990099", Small:"#0099C6"};

to:

var color = d3.scaleOrdinal(d3.schemeCategory20);

Does not work. What's the trick? Thanks and Great Work!!!

NPashaP commented 7 years ago

It will work, you will have to make sure that you supply the fill function correctly.

viz.bP().data(data).fill(d=>color(d.primary));

instead of

viz.bP().data(data).fill(d=>color[d.primary]);