2👍
✅
Using json_encode
would mean that you are encoding the data in JSON format. This format,may not be acceptable by chartjs
,as chartjs
requires strings for labels, and numbers for data.
Here is what you can do (only the required section of the code)
(Please Note):- Copy and paste this in label
tag in chartjs
. You can do this exact same thing for data
tag as well.
labels: [
<?php
for($i=0;$i<count($getDates);$i++){
echo $getDates[$i];
echo ',';
}
?>
],
Also, make sure to send the data as an array from the backend, if you want to use this method.
As for the random color thing, I suggest you check out this github repository. You can search for other options for random colors as well.
Source:stackexchange.com