Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

Stacked Charts

Open moohhoom opened this issue 10 years ago • 5 comments

Hi,

what about sorting the data series from highest to lowest in case of stacked chart, and do the same for the legends ??

moohhoom avatar Oct 10 '16 10:10 moohhoom

@moohhoom you can sort the datasets before creating the chart. We don't change the dataset order in the chart.

etimberg avatar Oct 10 '16 12:10 etimberg

I think moohhoom means that he wants to sort each individual bar by smallest to largest so that in the first bar where red represents series 1, red will be on the top because the value is small, but in the second bar, red will be on the bottom because the second value of series 1 is large. (Note: I think this is a bad idea.)

BenMic avatar Oct 13 '16 12:10 BenMic

@BenMic @etimberg what i meant is that if i have multiple series in any stacked support chart (bar,area ..etc) then i should see the series from smallest to largest starting from bottom to top (maybe based on avg,sum,min,max ..etc of the values in each series) also after that the legend should also be sorted to match what i am seeing on chart area, starting from left to right...

for example :

Series 1 = [ 7, 8, 9, 10, 11, 12] Series 2 = [ 1 , 2 , 3 , 4 , 5 ,6]

then on the chart based on the AVG of the values Series 2 should be under Series 1 ...

moohhoom avatar Oct 13 '16 12:10 moohhoom

This isn't currently possible, and it almost sounds like a new chart type

etimberg avatar Oct 13 '16 21:10 etimberg

Closing since we aren't going to implement this in the core. The best way to do this would be to create your own chart type that does this sorting

etimberg avatar Nov 19 '16 15:11 etimberg