You must be logged in to post your query.
Home › Forums › Chart Support › Rendering Chart from SQL Database
Currently I am working on rendering chart from SQL Database. However, I encounter problem that my x-axis showing the wrong value and my y-axis does not has any value. Any idea how can I work on this?
i think your data doesnt contain any usefull. Do you test with php echo or js alert the output?
let $arr your array from SQL, then you give canvasJS the data in a new array row with: json_encode($arr) see line two on line thre an example how to look for usefull data. Good luck!
window.onload = function () { var row = <?php echo json_encode($arr) ?>; // alert(row[1][‘datum’] );
var data = []; var dataSeries = { type: “spline”, fillOpacity: .0, lineThickness: 6, //color: “rgba(192,192,192,0.9)”, yValueFormatString: “#0.# °C”, toolTipContent: ” <span \”style=’color:#4F81BC’ align=’middle’\”><h2>{x}</h2></span><br><h2>{y}</h2>”, }; var dataPoints = [];
for (var i = 0; i < <?php echo $rows+1?>; i += 1) { //for (var i = 0; i < <?=$rows?>; i += 1) { //y += Math.round(Math.random() * 10 – 5); y=parseFloat(row[i][‘temperatur’]);
x=new Date(row[i][‘datum’]); dataPoints.push({ x: x, y: y }); } dataSeries.dataPoints = dataPoints; data.push(dataSeries);
and so on…
You must be logged in to reply to this topic. Login/Register