Wearybands
Wearybands

Reputation: 2455

Line Chart with jQuery Flot (Fix Start Time)

I have created a bar chart with jQuery Flot. It is a real time chart which starts with the current time and updates with time. I want to change the x-axis of this chart so that the start time does not disappear when it starts plotting, and it do some scaling after too many time intervals come on the x-axis.

Here is the chart I created Chart Link

My data is int this form

  function GetData() {
        var fast = parseInt(msg[1]);
    var ok = parseInt(msg[2]);
    var slow = parseInt(msg[3]);
    var data = [
           {label: "Fast", data:fast},
           {label: "OK", data:ok},
           {label: "Slow", data:slow}
    ];
        return data;
  } 

Can any one please help me out ?

Thanks

  Click on "Chart Link" to see the running chart

Upvotes: 0

Views: 401

Answers (1)

Mark
Mark

Reputation: 108567

In GetData just remove the "shifting" of the data:

// I commented out 3 lines!
function GetData() {
  //data.shift(); 
  //while (data.length < totalPoints) {     
    var y = Math.random() * 100;
    var temp = [now += updateInterval, y];
    data.push(temp);
  //}
}

Updated fiddle here.

Upvotes: 1

Related Questions