Closed MaciejMalczyk closed 3 years ago
Maybe you want to try chart.dispose()
I used chart.dispose() but all errors remains. Additionally i got this: I was thinking about this and maybe i need to remove and attach js script to avoid this.
Although I still don't understand why dispose
is not working for you, but with a fix in 0.5.1, It's not necessary to remove the parent div. Just call dispose
and reuse the same div to create a new TimeChart instance.
I've created an example to prove this works by continuously dispose and recreate the chart. It loops several hundreds of times without any problems. And no resource leak observed from the performance monitor in Chrome devtools.
Let me know if you still have any issues with this.
I used chart.dispose() but all errors remains. Additionally i got this: I was thinking about this and maybe i need to remove and attach js script to avoid this.
Of course, you should not update a chart after disposing it
I can confirm that calling dispose()
then recreating allows you to rebuild the chart without errors. I do this to clear the plotted data without issue.
Thank you for your help. I saw your example and after few days of thinking i found a way to avoid removing parent div to recreate new chart with chart.dispose(). Problem with remaining context was not in your lib but in my implementation.
I'm using chart.update() or/and chart.onResize() (i found that they have simmilar effect in adding new data) because live plotting is neccesary feature in my project so "Cannot update after dispose" or "Uncaught DOMException: Failed to set the 'value' property on 'SVGLength': Could not resolve relative length" (depends on what was used update() or onResize()) error still shows up but it not affects site performance and charts works normally. As far as i undestand this is expected in your lib.
I'm pushing your module to its limits :)
In my usecase i need to reset data from chart. As removing data is impossiible i decided to remove whole parent div (it is generated automaticly when proper function is called). With this method i can remove data but after removing div with chart and appending it again console complains about old WebGL contexts. After few resets amount of old contexts grow to 20 and more (i'm reseting multiple charts at once) and this affect performance. To remove all WebGL contexts i need to restart site.
Other but minor problem is chart.update(). After reseting a chart this function generates error about DOM.
Full errors below: