score:1

Accepted answer

please remind that $.ajax() makes an asynchronous http request. in you code however, you create the chart even before ans answer from that request is received.

the problem can be solved by moving the code responsible for chart creation inside the $.ajax() block as shown below.

$.ajax({
  success: function(response) {
    var jsonarr = $.parsejson(response);
    var k = 0;
    for (var key in jsonarr) {
      days[k] = jsonarr[key]["days"];
      values[k] = parseint(jsonarr[key]["values"]);
      k++;
    };
    var a = {
      labels: days,
      datasets: [{
        backgroundcolor: ktapp.getstatecolor("danger"),
        data: values
      }]
    };
    new chart(...);
  });

Related Query

More Query from same tag