0👍
ChartJS expects the data in a comma separated statement, such as:
data: 5, 7, 8, 9;
I suspect the json_encode is confusing it, and would suggest you return strings, rather than arrays:
$stmt=$pdo->prepare("SELECT * FROM asset_details");
$stmt->execute();
$json= "";
$json2= [];
while($row=$stmt->fetch(PDO::FETCH_ASSOC)) {
extract($row);
$json .= "'".$type."',";
$json2 .= (int)$manufacturer.",";
}
echo $json; // should be 'Red','Green','Blue' ...
echo $json2; // should be 5,6,9,4 ... etc
?>
- Chartjs-My charts doesn't work after inserting X-axis
- Chartjs-How can I avoid NaN on pie chart label in Chart JS
Source:stackexchange.com