Home Forums Chart Support Rendering Chart from SQL Database Reply To: Rendering Chart from SQL Database

#25200

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…