Search code examples
javascriptchartscallbackzingchart

Invoke callback function after zingChart.render()


I am rendering scatter plot using ZingChart.render() method. It is working fine and giving me the expected result.

I want to execute some code after graph rendering is completed. Since the JS code gets executed in an asynchronous manner, the code which I want to execute after graph rendering gets executed before the graph is rendered.

Is there any method in JS/ZingChart through which I can successfully execute some code after ZingChart's rendering is completed.

SampleCode.js

 zingchart.render({ 
      id:'chartDiv',
      data:chartData,
      height:400,
      width:600
    });

Sample line which need to be executed after ZingChart rendering is completed

performance.now()

Regards

Ajay


Solution

  • zing chart provides callbacks:

    zingchart.render({ 
      id:'chartDiv',
      data:chartData,
      height:400,
      width:600,
      events: {
         complete: function(p) {
              alert('complete');
         }
      }
    });
    

    Reference: https://www.zingchart.com/docs/developers/zingchart-object-and-methods/#render-method

    hope this helps