@elitriona,
It seems like you are not rendering the chart after updating the datapoints on ajax request. Calling chart.render()
after updating the datapoints will work fine in your case. Please take a look the code snippet below for the same.
$.getJSON('https://trionacgm.fly.dev/api/v1/entries.json?count=12', function(data) {
chart.options.data[0].dataPoints = [];
$.each(data, function(key, value) {
chart.options.data[0].dataPoints.push({
x: (value['date']),
y: Number(value['sgv'])
});
});
chart.render();
});
Also, check out this JSFiddle for complete working code.
—-
Manoj Mohan
Team CanvasJS