Chartjs-Bar Graph, chart.js PHP Will Not Load

2👍

The reason it’s not working is because, you are getting the response data as a JSON string not JSON object.

So, to make it work with ChartJS, you need to parse it first, using JSON.parse() method …

$(document).ready(function() {
   $.ajax({
      url: "prod_agg.php",
      method: "GET",
      success: function(data) {
         console.log(data);

         var data = JSON.parse(data);   //parse JSON string

         var date = [];
         var output = [];
         ...

Leave a comment