Articles in this section
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

Chart before clicking the button

The following screenshot displays Chart after changing fill color in button click

Chart after changing fill color in button click

JS Playground sample link: Chart Instance

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied