Flotr2 realtime chart

581 views Asked by At

Hi I'm coding a website that displays a chart using flotr2, I want it to print the graph in realtime each 30 seconds and showing the timestamp in the XAxis.

Currently I'm getting the data from a third party API with the following format:

{
"timestamp": "Thu, 19 Dec 2013 07:14:39 -0000",
"value": 50
}

The Y axis shows the "value" and the X axis should print the timestamp value each time I update the chart.

Any idea how could I get this working propperly?

Regards.

1

There are 1 answers

0
Dave On

Working on a similar thing, since what you wrote helped me fix my problem i wanted to note:

provided this is coming as a json and you are writing to a pie chart, rewrite it to:

var json =
    {
        "package": [
        {
            "data": [[0, 50 ]]
            ,"label": "Thu, 19 Dec 2013 07:14:39 -0000"
        }
    }

Then pass data to your function to redraw the chart

(function basic_pie(container, json.package) {
...