Can someone help me with why my code won’t render:
<?php
$dataPoints = array();
//Best practice is to create a separate file for handling connection to database
try{
$stmt = $conn->prepare(“SELECT created_on, sr_health FROM health_score_daily WHERE acct_id = $acct_id”);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
foreach($result as $row){
array_push($dataPoints, array(“x”=> $row[‘created_on’], “y”=> $row[‘sr_health’]));
}
$conn = null;
}
catch(\PDOException $ex){
print($ex->getMessage());
}
?>
<script>
window.onload = function () {
var chart = new CanvasJS.Chart(“chartContainer”, {
animationEnabled: true,
exportEnabled: true,
theme: “light1”, // “light1”, “light2”, “dark1”, “dark2”
title:{
text: “SuccessRocket (SR) Activity Score”
},
data: [{
type: “column”, //change type to bar, line, area, pie, etc
dataPoints: <?php echo json_encode($dataPoints, JSON_NUMERIC_CHECK); ?>
}]
});
chart.render();
}
</script>
<div id=”chartContainer” style=”height: 250px; width: 100%;”></div>
<script src=”/csm/canvasjs/canvasjs.min.js”></script>