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

Hidden data not applied on Pie chart when new dataset is added #6746

Closed
stockiNail opened this issue Nov 15, 2019 · 7 comments · Fixed by #7156
Closed

Hidden data not applied on Pie chart when new dataset is added #6746

stockiNail opened this issue Nov 15, 2019 · 7 comments · Fixed by #7156
Milestone

Comments

@stockiNail
Copy link
Contributor

Expected Behavior

When you add new dataset to an existing Pie chart and previously you hide a data by legend, the data at index (which should be hidden) shouldn't appear into chart.

Current Behavior

Using the CHART.JS sample. hiding a data of pie chart and then adding new dataset, the new dataset does not reflect the legend. See picture:

legendbug

Possible Solution

Before updating a chart, check with the legend that the data will apply the legend.

Steps to Reproduce

Using the CHART.JS sample:

  1. hide a data of pie chart by legend
  2. click on "Add Dataset" button

Environment

  • Chart.js version: 2.9.3
  • Browser name and version: FF 70.0.1
@benmccann
Copy link
Contributor

I'm curious if you use this hiding feature much or how you found the issue? We were somewhat wondering if it'd make sense or be possible to make it a plugin

@stockiNail
Copy link
Contributor Author

stockiNail commented Nov 15, 2019

@benmccann let me start with how I found the issue. Working on this CHARBA, project, a CHART.JS wrapper for GWT.

I've decided to develop a plugin to manage HTML legend in the project, to provide out of the box for the developers who want to manage legend in HTML to have more flexibility. You know that to build it in CHART.JS, some steps are necessary and I'm gonna provide everything by a plugin.

During my tests, I found this behavior. At the beginning I thought it was my mistake but, because I wasn't able to find out the bug, I decided to test also the sample of CHART.JS and I saw the same behavior.

In another application that I'm developing, the users are using this feature and I think it's nice.

In my opinion, it could be implemented into legend plugin.
Going to external plugin (if I understood you well), you should remove this feature to hide datasets/data but I don't think could be a good idea.

@yusufozturk
Copy link

@benmccann We also use this feature for custom zooming (we are not using chartjs zoom plugin)

In the initial load, chartjs only load aggregated data. When user zooms into specific date range, we bring the new data from backend, clear the chart and redraw it by new data. This help us to load huge timeseries data easily. If user chooses 6 months, we only bring every 1 hour aggregated data and every zoom can go into 1 minute intervals. Backend handles the intervals automatically based on the zoom range.

So if user hides a data via legend, during the clear/redraw data, we check if there is any hidden data by legend, so we make it sure that it's still hidden when new zoom range is selected.

Here is a demo via custom legends (using Datatables as a legend source):
http://37.1.145.200:8080/API/Query/Read?columns=counter:host:170:avg,counter:host:172:sum,counter:host:439:avg,counter:host:708:sum,counter:host:725:sum,counter:host:746:sum&groupBy=host&output=line&title=Overview&export=html&theme=dark&liveMode=6&legendposition=0&tooltipinteraction=0&access_username=chartjsdemo&access_usertoken=B279A21BD6D8FBDB576C781A98FC74CC

@benmccann
Copy link
Contributor

@yusufozturk I got an internal server error when trying to visit your link

@yusufozturk
Copy link

@benmccann Oh sorry, it's back again :)

@benmccann
Copy link
Contributor

Thanks. Ok, yeah, that looks very similar to the initial report. You update the graph on zoom and want any datasets previously hidden to stay hidden. I think the main difference is that your case is a line chart and so hiding/showing happens per-dataset and not per-data-point like with a pie chart

@yusufozturk
Copy link

@benmccann Yes that's true. I thought "removing hidden property" will affect also our case. If it's not, sorry for taking your time :/ Thanks!

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

Successfully merging a pull request may close this issue.

4 participants