Home forums Using CanvasJS Set ID of the generated CANVAS object

This topic contains 2 replies, has 2 voices, and was last updated by  MichaelCN 8 months, 4 weeks ago.

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

    MichaelCN
    Member

    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 9 months ago by  MichaelCN. Reason: Additional information given
    #19955

    Indranil Deo
    Member

    @michael,

    Yes, you can set ID for individual chart-canvas using chart.canvas.setAttribute("id", "chartCanvas"). Please take a look at this jsfiddle.

    ___________
    Indranil Deo,
    Team CanvasJS

    #19962

    MichaelCN
    Member

    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.