newuseruser
Posts: 5
Joined: Wed Jun 14, 2017 12:07 pm

Help with refreshing data automatically

Hello I created a chart here is my source code:
Highcharts.getJSON('/Sensor_eins.txt', function (data) {

// Create the chart
Highcharts.stockChart('container', {
rangeSelector: {
selected: 1
},

title: {
text: 'AAPL Stock Price'
},

series: [{
name: 'AAPL',
data: data,

tooltip: {
valueDecimals: 2
}
}]
});
});

how can I activate that the data is automatically refreshed every 5seconds??
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Help with refreshing data automatically

Hello,

You can use chart.events.load() callback function to add interval after the chart is loaded and use Highcharts.getJSON() method again to load the latest version of the data. You only need to add logic to add only new points.

Demo: https://jsfiddle.net/BlackLabel/vb4j9f5y/
API: https://api.highcharts.com/highcharts/chart.events.load

Let me know if you have any further questions!
Best regards!
Michał Filipiec
Highcharts Developer
https://blacklabel.pl/highcharts/

Return to “Highcharts Stock”