You must be logged in to post your query.
Home › Forums › Chart Support › Render graph in HTML Canvas
Tagged: Generate graph in an HTML canvas
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?
@ben-haestqed-lu,
The chart container has to be a div, not a canvas, as shown in the code snippet below:
div
canvas
<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
You must be logged in to reply to this topic. Login/Register