arpitnarechania / d3-dotmatrix

Open Source Javascript library to render Dot Matrix Charts
MIT License
14 stars 7 forks source link

how to set color gradients #2

Open weedkiller opened 5 years ago

weedkiller commented 5 years ago

hi, can you please update to resize, and also how can I setup up different colors, even a gradient using a scale of 1 to 10 or groups.

Trains - red People - blue people in trains blue/red

arpitnarechania commented 5 years ago

For different colors,

change this var color = d3.scale.category20(); to something like var color = d3.scale.ordinal().domain([<ARRAY OF CATEGORIES>]).range([<CORRESPONDING ARRAY OF COLOR MAPPINGS>]).

And while referencing this color scale, call using color(d["CATEGORY"]).

Regarding Resizing, let me add a function which does that. I will work on this over the weekend and update.

Thanks.