codesuki / react-d3-components

D3 Components for React
http://codesuki.github.io/react-d3-components/example.html
MIT License
1.63k stars 205 forks source link

changing the color of a grouped BarChart #118

Closed psudeepta closed 7 years ago

psudeepta commented 7 years ago

how to change the color of a grouped BarChart?Could you please provide some examples

solomein commented 7 years ago

Use d3 scales

const scale = d3.scale.ordinal().range(['red', 'blue', 'green']);

or custom function

const scale = value => { 
    // some color selection
    return 'black';
};

and pass as a prop

<BarChart
    groupedBars
    colorScale={scale}
/>
codesuki commented 7 years ago

Thanks again @solomein !

psudeepta commented 7 years ago

Thanks @solomein and @codesuki

It works as expected