1👍
The Problem with your code is that the echo will just output the content of the variable but as you are parsing it’s value into a javascript array you need to surround your value with quotation marks. So if you change
for ($i = 0; $i < count($data); $i++) {
echo $data[$i] . ",";
}
into
for ($i = 0; $i < count($data); $i++) {
echo "'" . $data[$i] . "',";
}
it should work. This will also solve your other problem. So with this change you should also be able to use the time.
- Chartjs-React-chartjs-2 how to set multiple background levels within a line chart
- Chartjs-Add Padding Right to Extended Line Chart in Chart.js V2
Source:stackexchange.com