smoothie
smoothie copied to clipboard
Destructor - Tooltip node
Hi, Is there a chart destructor which removes chart tooltip node?
Upon entering a view I'm creating chart instance and I would like to destroy it upon leave. I don't see a way to remove the tooltip node without using hacks.
Good point. An easy way to do this should be added.
For now, a quick workaround (based on this code) is:
// remove the tooltip element from the DOM completely
var tt = chart.getTooltipEl();
tt.parentNode.removeChild(tt);
Or to hide it, in case you need it back again later:
chart.options.tooltip = false;
chart.updateTooltip();
Or:
chart.getTooltipEl().style.display = 'none';
I haven't tested any of these snippets though.
If someone wants to put together a PR that addresses this issue, it'd be great.
cc @Sly1024, @jpmbiz70, @ralphwetzel
@gfduszynski I'm curious of the use case of why you want to remove the tooltip node or destroy it upon leave? Can you explain?
Thanks for quick feedback. I'm doing prototype UI in kiosk type device, based on raspberry pi compute module 3. Resources are somewhat constrained and I aim to keep node count low to maintain fluid animations.
I'm displaying 2 charts on one of my views. During daily use I estimate tooltip node count could grow to hundreds. Device will rarely be rebooted, so this will likely eventually lead to crash.
BTW: Suggested fix (first one) is good enough for me :+1: for now.