[Chartjs]-Redraw Chart.js Chart with Json_encoded array from ajax request

4👍

I’m an idiot, just needed the “json” type in the jquery ajax function, this question is probably pretty useful to someone else so here is what fixed it: dataType: “json”,

$.ajax({
     type: "POST",
     dataType: "json",
     url: siteUrl + "app/load_graph",
     data: {
      question_id: question_id
     },
     success: function(data) {

        //Get context with jQuery - using jQuery's .get() method.
        var ctx = $("#analytics-graph").get(0).getContext("2d");
        //This will get the first returned node in the jQuery collection.
        var myNewChart = new Chart(ctx);

        new Chart(ctx).Doughnut(data);

    } 
  });
});

Leave a comment