billboard.js
billboard.js copied to clipboard
onrender callback
Description
hello netil, first of all congratulations on your work! finding it was a deep sigh of relief! I only have one question about callbak 'onrender' - I noticed it is called 2-3 times for a chart and I am wondering if is this normal or I have made some mistake Thank you Ruggero
Hi @RuggeroN, onrendered
is called once, but it will be called whenever "redraw"(ex. window resize, etc.) happens.
hi Netil, thank you for replying so quickly; my doubt is that onrender is called several times during the initialization, before a manipulation of the graph. I noticed this by adding a console.log and I was wondering if it was possible to avoid it. thanks for your availability
Well, when you check the below example you'll see that rendered
logging will appear once during the initialization.
- https://jsfiddle.net/netil/avb197fL/
Maybe the container holding your billboard chart is resized during the initialization process of your site (that's what happens in my use case as well). Should be ok in this case as rendering the chart happens more than once.
@netil hi, sorry if i didn't answer earlier; as @GDFaber said, maybe there is something that triggers onRender. Is it possible that the management of the class within onRender makes it start again? thank you for availability
Is it possible that the management of the class within onRender makes it start again?
@RuggeroN, basically the redraw happens whenever internal .redraw()
is called. Basically is triggered from an explicit user interaction(resizing, toggling legend item, calling an API, etc.)
There's no observer observing element's class nor states, except lazy render case.