0👍
You’ll have to create an array of your data, then use json_encode
So an array like this :
$data = [
'data' => ['labels' => $labels],
'datasets' => $datasets
];
echo json_encode($data);
For $labels and $datasets : it’s also array that you can construct with your query results.
Your json will be like this : {'labels':..., 'datasets': ...}
- Chartjs-How to use Chart.js in A-Frame?
- Chartjs-How can I add vertical line and label for each point in Chart.js?
Source:stackexchange.com