Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dygraph: how to clear the graph data and reload it?

Tags:

graph

dygraphs

My application has refresh functionality in which all the present data on the graph should get cleared and data should be loaded from starting. I don't want to destroy the dygraph and recreate it but just need to clear the existing data and plot from starting. What I tried is

g.rawdata_ = null; g.updateOptions({'file': g.rawdata_});

But it throws the error. If i set rawdata to 0 and then try to update, it doesn't clear off the data. Any suggestion on how to do this?

like image 712
justcurious Avatar asked Sep 16 '13 11:09

justcurious


1 Answers

Just like the guys in the comments are saying:

plotData = [[0,0]];

g.updateOptions(
    { 
        'file': plotData
    }
);

plotData has to have something in it. You could probably put one of several different formats, but the above has worked for me in the past. I am live updating a plot as well and refreshing the data every second. To do that, I am preloading the plotData just before the updateOptions.

Good luck,

j

like image 144
slightlynybbled Avatar answered Nov 15 '22 11:11

slightlynybbled