Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to sort a combo chart's layer ? #2399

Closed
JSoon opened this issue Apr 28, 2016 · 25 comments
Closed

Is there a way to sort a combo chart's layer ? #2399

JSoon opened this issue Apr 28, 2016 · 25 comments

Comments

@JSoon
Copy link

JSoon commented Apr 28, 2016

Hello, there!
I'm here to ask question once again. Here is the issue:

I create a combo chart combine Bar with Line, and each of them has tooltips. When i hover a single point "in" a single bar, i can not hover over the point but get the tooltip of bar, looks like below:

1

And it should be supposed like this:

2

Any ideas? I mean, kind of like xAxesZIndex stuff ;)

@etimberg
Copy link
Member

@JSoon at the moment there is no way to change the order other than to have the bar dataset come first in the dataset array.

I think we can add something to allow custom sorting for drawing and custom sorting for the tooltips

@JSoon
Copy link
Author

JSoon commented Apr 29, 2016

Gotcha, looking forward to that.

@labs20
Copy link

labs20 commented May 4, 2016

A "z-index" of sorts is really needed.
Same problem here
+1

@LuisMCunha
Copy link

Also need this, +1

@codepassenger
Copy link

[Solved] Re-arrange Data Set. Declare Line before bar into Data Set.

@cogentParadigm
Copy link

This is not an ideal solution since the order of the Data Sets determines more than the stacking order. For example, it also controls the order of items in the legend.

@codepassenger
Copy link

I know this is not ideal solution but it give you some move.

@etimberg
Copy link
Member

More properly fixed in #3400

@lovanwubing
Copy link

@etimberg I think it is also better to have a order on the dataset. The current solution of "nearest" of tooltip is not perfect (I tried, and it seems not working).

In our project, we have quite lot of charts, all of them shares the same colors theme. The line datasetoverride has logic to be put behind bar datasetoverride. We really need the z-index solution for dataset. Thanks.

@tobzsc
Copy link

tobzsc commented May 17, 2017

+1, pretty good feature!

@maxflex
Copy link

maxflex commented Jun 8, 2017

Need this too

@lovanwubing
Copy link

@etimberg Is there any update on this feature ? I strongly suggest to have this feature, since the order of dataset will also affect the order of legend and tooltips. It's really not a good idea to change the order and have to config quite lot colors.

@PhilippMeissner
Copy link

+1, would be a very welcome addition..

@ChristofferArnlund
Copy link

+1 Need this! Use Case: using downsampling on all datasets except the last one, so I cat change the order of the datasets.

@omgkotofey
Copy link

+1, i have 10 different stats in my bar chart and it's looks bad, cuz of order.

Would be a perfect change)

@GuillaumeSerrat
Copy link

+1 a must!

@thesublimeobject
Copy link

i'm pretty surprised this hasn't been changed yet. this seems like a super important feature, to be quite honest. i ran into issues with it after only having used it for about 30-45 mins. i'm guessing this is way harder than it sounds, but could you not just add some kind of zIndex prop to the chart options?

@kurthamilton
Copy link

+1. I have multiple series in a line chart. Line colours are muted except for the one the user has selected. I would like to bring the selected line to the front without changing the order in the legend.

@JelleBlaauw
Copy link

Please revise this issue, as it's still relevant and required to this day.

@thesublimeobject
Copy link

@JelleBlaauw i completely agree. i'm unsure why the issue is closed given how many "likes" my last comment has received from almost a year ago. can anyone from the team comment on this issue?—i do not actively need this fix for anything, but i do like this library and use it for personal projects. i would be very happy and willing to submit a PR, or help in some way in the alleviation of this issue.

@tarockx
Copy link

tarockx commented May 3, 2019

Why was this issue closed? This seems like a very basic feature. I was experimenting with Charts.js for the first time and ran into this problem after just a few minutes of playing around with the line charts.

@benmccann
Copy link
Contributor

It looks like this was closed because it was implemented by adding an itemSort option: https://www.chartjs.org/docs/latest/configuration/tooltip.html#sort-callback

@tarockx
Copy link

tarockx commented May 3, 2019

Thanks for the reply, however this only addresses one of the side effects (tioltips) but not the root issue, which is that datasets are rendered in the order they are passed to the api, without the ability to set a "z-index" property. This causes other annoyances other than the tool tips (examples: needing to sort the datasets before passing them to the api causes legend entries to be out of order)

@sfaut
Copy link

sfaut commented Aug 23, 2020

Hi ! Some news about a dataset zIndex prop ?
Here I'd like to have groups 2 and 3 lines in front of group 1 bars.
I know I could reorder datasets elements and use options.legend.reverse = true, but here I prefer to put the main dataset first and more generally to be independant of the datasets order.
Thx,

image

@kurkle
Copy link
Member

kurkle commented Aug 24, 2020

There is the order property that you can use: https://www.chartjs.org/docs/master/charts/line#general

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests