Home Forums Chart Support Render graph in HTML Canvas

Render graph in HTML Canvas

Viewing 2 posts - 1 through 2 (of 2 total)
  • #45159

    Im created a canvas in the HTML Block, name myCanvas.
    <div>
    <canvas id=”myCanvas” style=”border:1px solid #000000; margin-right: auto; margin-left: auto; display: block;”></canvas>
    </div>

    In a script I want to create a graph but this does not seem to work:

    var chart = new CanvasJS.Chart(“myCanvas”,{
    title :{
    text: “Live Data”
    },
    axisX: {
    title: “Axis X Title”
    },
    axisY: {
    title: “Units”
    },
    data: [{
    type: “line”,
    dataPoints : dps
    }]
    });

    chart.render();

    I just copied some code from the examples, but even that does not seem to work.
    Does ConvasJS only work when the id= a block, or is there a way to make it work with a canvas?

    #45165

    @ben-haestqed-lu,

    The chart container has to be a div, not a canvas, as shown in the code snippet below:

    <div id="myChart" style="border:1px solid #000000; margin-right: auto; margin-left: auto; display: block;"></div>

    Please take a look at this docs page for a step-by-step tutorial on creating a chart.


    Thangaraj Raman
    Team CanvasJS

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

You must be logged in to reply to this topic.