If I’m charting an account balance in a line/bar chart, it’d be nice to show positive values in, say, black and negative values in, say, red. Right now that doesn’t seem to be an option. The thresholds/ranges should eventually be configurable so that 0
isn’t the only threshold and that there could be multiple ranges/bands of fills. This might only be for fills. Fill color boundaries could be abrupt or possibly a gradient mesh effect?
7 thoughts on “Dataset colors: option for different colors for negative values?”
Comments are closed.
+1 This is exactly what I need, I found a script to extend the line chart for v1.x but it’s not working anymore for v2.x
It could be nice to have fillPositive: and fillNegative option, and of course backgroundColorPositive, backgroundColorNegative.
@matfrog you can do this manually in v2.
When you set the
backgroundColor
property of the dataset, set it as an array of colors. The first color in the array will be used for the first bar, the second color for the second bar, etcClosing since this is doable manually. At this point, I don’t think we’ll build this into core directly. It could certainly live in user space though as a plugin.
@PTruscott this works fine. See https://jsfiddle.net/c1w5Laee/
@etimberg if all values gone positive, will give error:
Works fine with at least one value negative: See https://jsfiddle.net/c1w5Laee/78/
But has any thing wrong if all values are positives (with no value negative): See https://jsfiddle.net/c1w5Laee/80/
Can we achieve this in Angular along with chart.js and ng2-charts