Skip to content

Updating graph #135

Open
edasque opened this Issue Oct 10, 2012 · 10 comments

8 participants

@edasque
edasque commented Oct 10, 2012

I can't just addData, I get a whole new data set of 120 points every 10 seconds.

Should the following work:

        graph.configure({series: graph_data});

        graph.render();

I don't see my graph updating and from what I can tell, my series hasn't been updated either, looking at graph.series

What am I missing? Can configure not update the series, is addData the only way but it cannot completely replace the data? is Rickshaw.Series.FixedDuration the way?

@csmithmaui

I am trying to do the same thing but I haven't figured it out yet. I have been able to add/remove lines by pushing/popping from an array of series here http://jsfiddle.net/csmithmaui/pgx72/ but I am not having much luck in my acutal code.

@dchester

We could definitely do a better job at supporting this particular use case. At the moment, you have to reach in and manipulate data attributes of the objects in graph.series directly, and then call graph.render().

@abarre
abarre commented Oct 12, 2012

@dchester, do you have a working example for this case?

Do we have to modify both seriesand stackedDataattributes?

I did something like that but it is not working (the graph is not updated).
In the example, the graph is generated from the ajax wrapper.
By the way, I see some issues saying that we have to use the addData function but there is not addData function in the series' attributes.

var 
    i,
    j,
    len = newData.length,
    len2 = graph.stackedData[0].length;

for (i= 0; i < len ; i ++) {
    graph.series[i].data = newData[i].data;
    for (j = 0; j < len2; j ++) {
        graph.stackedData[i][j] = {
            x : newData[i].data[j].x,
            y : newData[i].data[j].y,
            y0 : 0
        };
    }
}

graph.update()
@edasque
edasque commented Oct 15, 2012

I haven't been able to get this working by modifying the series directly or through configure.

@abarre
abarre commented Oct 15, 2012

Ok @edasque,

If you could share the code you use to update the graph, it would help me.

Regards,

@edasque
edasque commented Oct 16, 2012

I did this which worked:

        graph.series[0].data=graph_data;
        console.log("Updating graph, got new data. Most recent: "+graph_data[graph_data.length-1].y)
        graph.update();

Ideally you'd be able to modify the data with a method call of graph instead of having to access the member variable directly.

@ergo
ergo commented Jan 16, 2013

my fork adds support for this properly i think,

this commit in particular:

ergo/rickshaw@d2e75b9
X, Y axes gets updated, just legend needs to be fixed.

now we need to get this to trunk :-)

@zanetaylor

It would be great to get this in place.

@eladmoshe

+1

@maxcal
maxcal commented May 10, 2014

+1

Here is an example that worked for me to replace all series:

series = [
    {
        name: 'Sexiness',
        color: "#3064B8",
        data: data[0]
    },
    {
        name: 'Alcohol consumption',
        color: "#91B4ED",
        data: data[1]
    }
];

$(graph.series).each(function(i){
    graph.series[i] = series[i];
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.