Home › Forums › Chart Support › JSON and the Line Chart › Reply To: JSON and the Line Chart
I am really new to canvasjs I need to create a running line chart based on data from database. What I did is something like this, error comes like Uncaught ReferenceError: $ is not defined at window.onload (livechart.php:7). Always shows.. Please help me with this..Thank you so much for any reply
window.onload = function () { $.getJSON("www.website.com/livedata.php", function(result){ var dps = []; // dataPoints var chart = new CanvasJS.Chart("chartContainer",{ zoomEnabled:true, panEnabled:true, animationEnabled:true, title :{ text: "Analysis for Soil Ph", fontSize: 20 }, data: [{ type: "line", dataPoints: dps }] }); var xVal = 0; var yVal = 100; var updateInterval = 100; var dataLength = 500; // number of dataPoints visible at any point var updateChart = function (count) { count = count || 1; for (var j = 0; j < count; j++) { yVal = yVal + Math.round(5 + Math.random() *(-5-5)); dps.push({ x: xVal, y: yVal }); xVal++; }; if (dps.length > dataLength) { dps.shift(); } chart.render(); }; updateChart(dataLength); setInterval(function(){updateChart()}, updateInterval); }); }