reaviz
reaviz copied to clipboard
Add option to not sort series in grouped area chart
I'm submitting a...
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Performance issue
[x] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:
- [x] willing to submit a PR
Current behavior
Currently, grouped line/area charts have their series sorted by median value. There is no option to not have the data sorted.
https://github.com/reaviz/reaviz/blob/9e2f03ce9451a11e5e0562aab8b0b06f15abfcc8/src/AreaChart/AreaChart.tsx#L136
there also seems to be similar calls of buildNestedChartData(..., true)
on the radial charts, but haven't been using them so won't comment too much on them.
Expected behavior
I'd like there to be some way to indicate that the data shouldn't be sorted, likely in the form of a prop on either AreaSeries
or AreaChart
What is the motivation / use case for changing the behavior?
I have a color scheme I'm using for a set of data across various charts, and want the color for each series to be the same across charts. However, since the the area chart sorts its series, the chart ends up with series having their colors mixed up. e.g.
data series | intended color | median | color in chart |
---|---|---|---|
A | red | 4 | red |
B | orange | 1 | ❌ green |
C | yellow | 3 | yellow |
D | green | 2 | ❌ orange |
colors [red, orange, yellow, green]
data [A, B, C, D ]
sorted data [A, D, C, B ]
Minimal reproduction of the problem with instructions
https://stackblitz.com/edit/vitejs-vite-h9ejte?file=src%2FApp.jsx
Desired is preserving the order A -> B -> C -> D along with their corresponding colors red -> orange -> yellow -> green