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

On re-render or redraw save the state of dataset and sires that was hidden Chart.js V2

Open MishaBeskin opened this issue 10 years ago • 7 comments

Hi, I using chart.js V2 with Angular, My problem currently is that when I hide some sires on my graph, and then change the date of the graph(the graph renders ok with specific data for the selected day, but the graph shows all sires again instead to show only the sires that had stayed visible). As I understand currently it not save or store the state of hided sires and legends that was hided previously. Maybe I missing some option on the Chart.js documentation. Here small video of the behavior: http://screencast.com/t/e2Y7lqtxJ1Iu Thanks.

MishaBeskin avatar Sep 22 '16 05:09 MishaBeskin

are you recreating the chart?

etimberg avatar Sep 22 '16 19:09 etimberg

Yes,

On Sep 22, 2016 10:43 PM, "Evert Timberg" [email protected] wrote:

are you recreating the chart?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/chartjs/Chart.js/issues/3344#issuecomment-249007467, or mute the thread https://github.com/notifications/unsubscribe-auth/AFEGqRnI2VMsU52sNKYZr5BisvJwWwAkks5qstpfgaJpZM4KDi_v .

MishaBeskin avatar Sep 23 '16 04:09 MishaBeskin

You need to add hidden: true to any datasets that were hidden previously.

etimberg avatar Sep 24 '16 00:09 etimberg

where exactly I need to add this ?

Thanks in advance

Misha Beskin ():-)

Email: [email protected] [email protected] Website:www.feedbacksign.com Skype: Misha Beskin

Phone: +972545203269

On Sat, Sep 24, 2016 at 3:11 AM, Evert Timberg [email protected] wrote:

You need to add hidden: true to any datasets that were hidden previously.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/chartjs/Chart.js/issues/3344#issuecomment-249329869, or mute the thread https://github.com/notifications/unsubscribe-auth/AFEGqVZPO8op7AojrZbB3gwx62qjqzykks5qtGq3gaJpZM4KDi_v .

MishaBeskin avatar Sep 26 '16 07:09 MishaBeskin

Inside the datasets in the data object. To determine the visibility of a dataset in the chart you can use chartInstance.isDatasetVisible(datasetIndex)

etimberg avatar Sep 26 '16 15:09 etimberg

@MishaBeskin recreating the chart is usually not a good way to update data. Instead, you can update the datasets data object and call chart.update(). Hopefully it should fix your issue without dealing with saving the previous states.

simonbrunel avatar Oct 01 '16 13:10 simonbrunel

Closing as answered

etimberg avatar Oct 05 '16 22:10 etimberg