Default Multigraph view - v8.3.5

I seem to remember in earlier versions, if you created a multigraph, whatever time period the graph was set when it was saved would become the default view whenever it was viewed in a dashboard. But that feature no longer appears to work, and it constantly defaults back to the Week view.

For example, create a multigraph, select Day view and save. Import the multigraph into a dashboard and it opens in Week view.

...or am I mistaken!

 

Paul

pb66's picture

Re: Default Multigraph view - v8.3.5

Well I never ya learn something new everyday !

I just tried this on emoncms.org which is v8.3.5 and it works exactly as you describe, I never knew you could do that with multigraph's, that's a neat little feature.

So no, you are not mistaken...

Paul

Paul Reed's picture

Re: Default Multigraph view - v8.3.5

....Hhmm, so why doesn't it work on v8.3.5 self hosted installation?
Just deleted the Multigraph, and tried again, and still get the same result - 'Week' view instead of 'Day'.
Checked the Multigraph MYSQL table and it has saved the default view as;

"timeWindow":604800000

..which is the number of Milliseconds in a week, but by editing it to 86400000, the dashboard view now defaults to 'Day' view by default.

For some reason when saving multigraphs, it is not saving the 'user selected' time window.

Paul

pb66's picture

Re: Default Multigraph view - v8.3.5

I've tried this on a local install now and can confirm the timeWindow is not being saved when editing a multigraph, on self-hosted v8.3.5.

Although I tried to find the cause I couldn't work it out - lack of js and php knowledge !

What I did find was the value that is saved to the db is determined at L259 of multigraph_edit.js and this value (or rather the difference between "start" and "end") doesn't change when a "timeWindow" is selected.

If you set the values in the db directly that works ok until you edit something on the multigraph, then the value gets overwritten with 604800000 again.

I suspect (but I'm far from sure) the start and end variables are no longer updated as view.start and view.end are now used in place of start and end in mutigraph.js, I've tried a couple of "fixes" without success, 

Paul

 

Paul Reed's picture

Re: Default Multigraph view - v8.3.5

Yes, I've also tried & failed!

Paul

JBecker's picture

Re: Default Multigraph view - v8.3.5

Does it possibly have something to do with the commented line 138 in multigraph.js?

The variable multigraph_editmode does not seem to be used for anything.

Jörg.

JBecker's picture

Re: Default Multigraph view - v8.3.5

I also have a lot of problems to understand the code and the meaning of the numerous variables. In lines 158-160 in multigraph.js a variable timewindow is initialized but does not seem to be used. Then view.end and view.start are set in a different way than in all other places (where start and end are used?). (view.end = + new Date) instead of (end =  (new Date()).getTime()) which is done everywhere else.

Hmmm, time to learn js and php maybe ......

pb66's picture

Re: Default Multigraph view - v8.3.5

I had another stab a this and changed the "start" and "end" vars to "view.start" and "view.end" in multigraph_edit.js, which seems to work ok once apache is restarted and page refreshed.

To see the changes and edit manually (add "view." in 5 places) see the pull request on GitHub 

Paul

Paul Reed's picture

Re: Default Multigraph view - v8.3.5

That's good news. I didn't think that you would let it beat you!!

Paul

Comment viewing options

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