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

onrender callback

Open RuggeroN opened this issue 3 years ago • 6 comments

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

RuggeroN avatar May 03 '21 16:05 RuggeroN

Hi @RuggeroN, onrendered is called once, but it will be called whenever "redraw"(ex. window resize, etc.) happens.

netil avatar May 04 '21 01:05 netil

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

RuggeroN avatar May 06 '21 09:05 RuggeroN

Well, when you check the below example you'll see that rendered logging will appear once during the initialization.

  • https://jsfiddle.net/netil/avb197fL/

netil avatar May 11 '21 00:05 netil

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.

GDFaber avatar May 14 '21 12:05 GDFaber

@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

RuggeroN avatar May 17 '21 15:05 RuggeroN

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.

netil avatar Jun 10 '21 07:06 netil