Is it possible to change the Bar fill color based on a value in the data set?
See original GitHub issueI’d like to make the fill color for the column “Current” to be different to the other bars. Would appreciate any help for doing this. Note that the data gets sorted so the order of the bars changes.
Many thanks.
This is what my data looks like.
export default ({coverAmount, rates, current}) => { const data = sortData([ {years: 'Current', premium: parseFloat(current), buffer: 0}, {years: 'R10,000', premium: 10000 * rates[0], buffer: Math.round((10000 * rates[1])/3)}, {years: 'R20,000', premium: 20000 * rates[0], buffer: Math.round((20000 * rates[1])/3) }, {years: 'R30,000', premium: 30000 * rates[0], buffer: Math.round((30000 * rates[1])/3) } ]);
and the Bar statements
<Bar stackId="a" dataKey="premium" fill="#005599" /> <Bar stackId="a" dataKey="buffer" fill="#007700" label/>
Issue Analytics
- State:
- Created 7 years ago
- Comments:8
Top GitHub Comments
Thank you. This helped me better understand things.
I came across an example using the Cell component and now have it close to what I want with the following code:
@gplatt thanks for the example. There is one additional simplification available:
using
entry
instead ofdata[index]