You must be logged in to post your query.
Home › Forums › Chart Support › Set ID of the generated CANVAS object
Hi CanvasJS Support Forum,
is there any possibility to set the ID of the HTML CANVAS object that is created by var chart = new CanvasJS.Chart("chartContainer", {... ?
var chart = new CanvasJS.Chart("chartContainer", {...
The name “chartContainer” just labels the DIV, that contains the CANVAS. <div class="canvasjs-chart-container" style="position: relative; text-align: left; cursor: auto;">
<div class="canvasjs-chart-container" style="position: relative; text-align: left; cursor: auto;">
It would be nice for us, if the generated CANVAS itself could be labelled with an ID.
i.e.: <canvas id="myChartContainer" class="canvasjs-chart-canvas" width="1234" height="370" style="position: absolute;">
<canvas id="myChartContainer" class="canvasjs-chart-canvas" width="1234" height="370" style="position: absolute;">
Is there any possibility to do that?
Reason: We are trying to auto-zoom (strechX, strechY) the chart in dependency of another, existing canvas object on the page. Therefore it would be required to have a handle to the CANVAS container of the graph.
Thanks a lot in advance, Michael Mann
Michael,
Yes, you can set ID for individual chart-canvas using chart.canvas.setAttribute("id", "chartCanvas"). Please take a look at this JSFiddle for complete code.
chart.canvas.setAttribute("id", "chartCanvas")
___________ Indranil Deo Team CanvasJS
Thank you very much for your help!
Best regards, Michael Mann
You must be logged in to reply to this topic. Login/Register