Home Forums Chart Support Chart Not Displaying Reply To: Chart Not Displaying

#17201

Malik,

In the example provided it seems like chart is being rendered and then data is being parsed and added to the dataPoints array. The dataPoints are shown once if you press f12, due to chart.render() being called automatically while the window resizes (which is the defualt behaviour).

In order to render the chart with the dataPoints, you just have to call chart.render() inside the Ajax call.
Please take a look at the code snippet below,

$.getJSON(“myfile.php”, function (result) {

  $.each(result[0], function (index, Info) {
    dataPoints_1.push({
      x: Info.x,
      y: Info.y,
      label: Info.label
    });
  })
  $.each(result[1], function (index, Info) {
    dataPoints_2.push({
      x: Info.x,
      y: Info.y,
      label: Info.label
    });
  })
  chart.render();
}); 

rendering chart from ajax data


Suyash Singh
Team CanvasJS