Search code examples
javascriptcanvasjs

How can i get access to a canvasJS chart through a DOM-Container


When i render a canvasJS-chart to a div container, how can i get access to the chart object through the div-Container? i dont want to make the chart variable global.

I want to use it as: var chart=$(“#container”).canvasJS();

Any ideas please.

Answer in this link is not working https://canvasjs.com/forums/topic/how-can-i-get-access-to-a-canvasjs-chart-through-a-dom-container/


Solution

  • You can access Chart-Container in CanvasJS jQuery Charts using $("#container").CanvasJSChart();. In your case it may not be working as you are using lowercase c in CanvasJS(), .