[Chartjs]-Chart.js PHP to JS string conversion question

1👍

The issue is, that you are constructing the data property of the $row[] as string and not as an array. See below, how to fix this issue:

...
$row[] = 
    array(
        'label' => "Uitslag",
        'backgroundColor' => "rgba(146,196,213,0.2)",
        'data' => array($autonomie, $competentie, $verbondenheid, $vrijheid, $welbevinden, $energie)
    );
 ...

Then the json should be constructed correct, and the chart should work.

Tipp: Just construct your desired data – structure, in the usual PHP fashion (as needed), and than pass it to the function json_encode. It will do the heavy lifting, of converting it into valid json.

Leave a comment