Multigraph automatic update

Hi @all emoncms friends,

Is there a way to update the Multigraph dynamically? Maybe via the vis_slowupdate() function?

Tried to call vis_Draw() function but had no success.

 

Thanks

jonbev's picture

Re: Multigraph automatic update

Could you refresh the iframe on a timer?

D.Schmidt's picture

Re: Multigraph automatic update

I don't want to update the whole iframe, because when I have already zoomed into the Multigraph, on every refresh (in my understanding) the Multigraph would be set back to default view. Any other ideas?

D.Schmidt's picture

Re: Multigraph automatic update

I got it. Inserted in function multigraph_init() an Interval with setInterval(function () {inst_refresh(); vis_feed_data();},time);

In inst.js I declared a new function inst_refresh()

 { var timewindow = (end-start); timeWindowChanged = 0; }

That works fine for me.

engeeaitch's picture

Re: Multigraph automatic update

Hi - I am interested in doing this as well.  I tried your solution, but it didn't work for me.  Could you post the modified files somewhere please (or a snippet so that I can see exactly how to insert the code).  Many thanks.

D.Schmidt's picture

Re: Multigraph automatic update

There are two files you have to modify:

  • Modules/vis/visualisations/common/inst.js

add this function:

function inst_refresh() { var timewindow = (end-start); timeWindowChanged = 0; }

 

  • Modules/vis/visualisations/multigraph.js

Look for "function multigraph_init(element)" and add following snippet to the very end of it:

setInterval(function () {inst_refresh(); vis_feed_data();},20000);

 

To make sure you get it running I attached the modified Files.

 

 

o_cee's picture

Re: Multigraph automatic update

D.Schmidt: Would it be possible for you to submit this as a pull request on GitHub? Would be nice to merged to the main branch for everyone to use?

elyobelyob's picture

Re: Multigraph automatic update

I'm finding (by looking at firebug console), that it is calling the same data e.g. feed/data.json?&id=2&start=1360847478146&end=1360933878146&dp=400 .. so, the start and end times aren't changing .. I still need to hit a menu D to update the data.

darrepac's picture

Re: Multigraph automatic update

Is there something working to make the multigraph to refresh automatically without losing the current zoom?

zaxter's picture

Re: Multigraph automatic update

@darrepac I'm looking for exactly the same thing! Did you find any solution yet?

zaxter's picture

Re: Multigraph automatic update

I'm looking for the exact same thing. Anyone found a solution yet?

I tried D.Schmidt's solution but it didn't work as I wanted it to. :(

zaxter's picture

Re: Multigraph automatic update

This is for anyone who wants an auto updating multigraph that pans right periodically in zoom as well.

I borrowed @D.Schmidt's solution (from above) which although automatically updates (redraws) the multigraph, it doesn't pan-right periodically when zoomed. I thus added a bit of my own code to get the periodic pan right in zoom.

Please forgive my rather crude and inelegant approach (given that this is my very first attempt at js) but it works for me. :)

 

1. First add the following functions to Modules/vis/visualisations/common/inst.js:

 

function inst_increment()
  {
    var laststart = start; var lastend = end;
    end = (new Date()).getTime() - 30000;    //sets the updated end time to 30 secs behind the current time,
    var timeWindow = (end-start);
    var shiftsize = timeWindow * 0.01;
    start += shiftsize;
    end += shiftsize;
    timeWindowChanged = 1;
  }

And-> 

function inst_refresh()
  {
    inst_increment();
var timewindow = (end-start);
    timeWindowChanged = 0;
  }

 

2. Then add the following at the very end of the multigraph_init() function in Modules/vis/visualisations/multigraph.js:

 

setInterval(function () {inst_refresh(); vis_feed_data();},10000); 

 

3. You may want to add a button which when pressed will automatically zoom to the required time frame and begin panning right periodically. For eg. if you wanted something similar to the 'D', 'W', 'M' buttton for hours or minutes, you can add something like this:

 

"<button class='btn time' type='button' time='0.01'>Set</button>"+

 

Playing with the hardcoded values, one would be able to adjust the time window and refresh rate.

 

Thanks. 

 

micha's picture

Re: Multigraph automatic update

Hello zaxter,

 

it doesn't work at all. The SET button works, but there is no automatic update of the multigraph. Should happened every 30 s, isn't it?

 

I like to update the graph every 5 s. Is this possible?

 

Thanx, Micha.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.