Home Forums Chart Support Set ID of the generated CANVAS object

Set ID of the generated CANVAS object

Viewing 3 posts - 1 through 3 (of 3 total)
  • #19946

    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", {... ?

    The name “chartContainer” just labels the DIV, that contains the CANVAS.
    ​<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;​">​

    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

    • This topic was modified 6 years, 9 months ago by MichaelCN. Reason: Additional information given
    #19955

    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.

    setting id for chart canvas

    ___________
    Indranil Deo
    Team CanvasJS

    #19962

    Thank you very much for your help!

    Best regards,
    Michael Mann

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.