You must be logged in to post your query.
Home › Forums › Chart Support › How can i get access to a canvasJS chart through a DOM-Container
Tagged: dom canvas object
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();
Ayny ideas please.
@donwey,
You can get access to the chart object using $("#container").CanvasJS().
$("#container").CanvasJS()
——- Sanjoy Debnath, Team CanvasJS
It is not workin @Sanjoy
@merajahmed,
$("#container").CanvasJS() will work with jQuery Charts. In case you have some other requirement please create a jsfiddle so that we can understand your requirement better and help you out.
___________ Indranil Deo, Team CanvasJS
See this link jsfiddle See the console. It says $(…).CanvasJS is not a function
Please use var c = $("#chartContainer").CanvasJSChart();. Also take a look at this updated jsfiddle.
var c = $("#chartContainer").CanvasJSChart();
And please use the jQuery plugin (https://cdn.canvasjs.com/jquery.canvasjs.min.js) instead of Javascript.
@Indranil Deo,
I have used your described code but still not not working. Using the same canvasjs.min.js library you provide.
@vipinrana,
Since you are using the jQuery selector var c = $("#chartContainer").CanvasJSChart();, please use the jQuery plugin (https://cdn.canvasjs.com/jquery.canvasjs.min.js) instead of Javascript.
Same thing I would like to access with the angular js version of canvas js library I would like to access the CanvasJS object from DOM elmenet using angular js.
@darshanjain,
It’s not possible to access chart based on the DOM element in angular. However if you are using jQuery plugin, you can do so using jQuery selector var c = $("#chartContainer").CanvasJSChart();.
___________ Indranil Deo Team CanvasJS
@Indranil, Then what is the other way to do it in angular with (canvas.min.js)?
It’s not possible to access chart based on the DOM element in angular, as of now.
@Indranil Deo How to create feature request for it(to access chart based on the DOM element in angular)? and what is best way to track the progress on it?
Hello guys any update on How to create feature request for it(to access chart based on the DOM element in angular)?
@rupeshelimu2021,
You can use CanvasJS jQuery plugin in Angular to access the chart based on DOM element. Please download this sample project for an example.
You must be logged in to reply to this topic. Login/Register