Category / Section
How do I get the instance of chart control?
1 min read
It is possible to get the object of the chart after rendering the control with the help of instance method. The following code example shows you how to get the chart object in a button click. Using this object, you can change the chart properties and redraw the chart again.
<button onclick="display()">Click</button> <div id="container"></div> <script type="text/javascript"> $(function () { $("#container").ejChart(); }); function display() { var chart = $("#container").ejChart("instance"); chart.model.series[0].fill = "blue"; $("#container").ejChart("redraw") } </script>
The following screenshot displays Chart before clicking the button
The following screenshot displays Chart after changing fill color in button click
JS Playground sample link: Chart Instance