Khanh Pham
Khanh Pham

Reputation: 2973

Jquery Flot not update x-Axis realtime

I had a problem with jquery flot.

I want to update realtime x-axis every 5 seconds. But it only update x-axis a little time, and after that, it didn't update label x-axis.

Can anybody explain for me, why it din't update ? Thank you very much.

Here my link demo: This is my demo

enter image description here

Upvotes: 1

Views: 227

Answers (1)

Raidri
Raidri

Reputation: 17550

You only define your xaxis ticks once and never update them when the data changes. So they move out of your chart to the left.

Add the following code to your GetDataHour() function to add new ticks every hour when you add new data:

if (now_hour - options_hour.xaxis.ticks[options_hour.xaxis.ticks.length - 1] === 3600000) {
  options_hour.xaxis.ticks.push(now_hour);
}

See the updated fiddle for the full code.

Upvotes: 1

Related Questions