Chartjs-Js error: while trying to display graph using chart.js: Uncaught TypeError: Cannot read property 'call' of undefined

0👍

As stated in the docs for print_r(): “Prints human-readable information about a variable”. Human-readable information is rarely useful to a computer.

Instead, you want the data in a format that can easily be parsed by your program. In the case of chart.js, that format would be JSON. You’re already JSON-encoding the data, you just need to stop wrapping it in the extra formatting that comes along with print_r(). Instead, simply just output the data with echo.

var WData = <?php echo json_encode($WData);?>;

Leave a comment