Allow conditional colouring for lines in bidimensional line graphs #3604
KaelanFrey posted onGitHub
- I have searched the issues of this repository and believe that this is not a duplicate.
What problem does this feature solve?
The end user should be able to see a single line graph with different colours depending on a line segment's starting Y value.
What does the proposed API look like?
Usage example, if we wanted to colour depending on a Y value called "value", pivoted by a "date":
const lineView = chart.createView({
padding: 32
});
lineView.data(data.lineData);
lineView.scale('value', {
alias: 'Value'
});
lineView.line()
.position('date*value')
.color('_*value', (_,v) => v > 40000 ? 'green' : 'red');
That would create a view where each line that would start on a point with a value higher than 40000 would be green, or red if not. This is exactly how points handle colouring, but the same logic is not applicable to lines.
EDIT: Currently, calling .color
like that will colour the whole line depending on the value of the last value. It should be possible to colour segments of the line. A final example would be something like this:
<!-- generated by antv-issue-helper. DO NOT REMOVE -->