Home › forums › Using CanvasJS › Getting an Object Reference to a Chart
This topic contains 1 reply, has 2 voices, and was last updated by Suyash Singh 1 year, 9 months ago.
How does one get a reference to an existing chart. Let say I have created a chart during the window.onload() event. Later, e.g. following a user configuration change request, I want to modify the chart configuration. How to I proceed to get a reference to the existing chart from outside the window.onload() event or from outside the method in which it was originally defined?
You can get the reference of the chart object outside of the window.onload() or any other function by either creating chart as a global variable, which is not a neat way to access the chart. Or you could pass the chart object as a parameter to the function that can access the chart as shown in this jsfiddle.
You must be logged in to reply to this topic.