Emoncms Graph module developments

Right! lets try again!

There is a change but it’s still not right.

If I freshly select a new feed with a RH checkbox it’s no different, still “undefined undefined”.

However. If I move a feed from the left to the right but just clicking the RH box of a feed that already has it’s LH box ticked, the tag and name persist. (previously it would change to “undefined undefined”)

Do the same test again but deselect the LH box before selecting the RH box and it’s “undefined undefined”.

So the code for the RH box cannot determine new values but it can retain existing data, So for now a work around is to momentarily selct the LH box before the RH box for RH scaled feeds.

Sorry about the false start, multitasking never pays off !!

EDIT - Also to add to that if you select RH first then LH the “undefined undefined” remains, it does not correct unless you deselect and reselect the LH box.

Yes at the moment the way it works is that it copies over the feed id, name and tag to the graph object when you create the graph which means that if you change the feed name the name is not updated. This saves a feed list api call for every graph load (which could be a large number of api calls on a large dashboard) but perhaps its an optimisation that will lead to more confusion than its worth…

How do the existing dash elements/widgets work? do they fetch or retain the feed names? IMO if I edit the feed name in the Feeds page I would expect it to change everywhere. Obviously graph titles and dashboard names based on feed names wouldn’t change but I think the legend should, especially with the table below parsing the feedid:tag:feedname would that then actually be giving false info?

Also, I’ve just noticed the Min and Max applied to the LH scale are being applied to the RH scale.

This pic shows my usual cpu_temp example with solar_power added to the RH scale (hence the “undefined undefined”) the PV array is currently producing well over 10kW, so the solar_power is 10,000+ but goes of the scale at 70.

The y-axis min and max applies to both axes at the moment. Il look into what I can do on the legend feed names.
The public accessibility in dashboards is also a little more complicated than I thought, as at present the saved graph object contains all saved graphs for a given user and is requested using the userid which is not stored in the parameters for the graph embedded in the dashboard… which means each saved graph will likely need its own id, in much the same way as the multigraph id to be accessible.

I’ve now re-implemented the way the graph module saves its graphs to enable use in public dashboards. I’ve updated emoncms.org with the changes including running a migration script to copy over graphs already created on there.

Dashboards however still need to be rebuilt to load the graphs as the parameters saved in the dashboard have changed from graph name to graph id + a full page refresh will likely be needed to reload the javascript for the dashboard.

For anyone who wishes to run the migration script on self-hosted emoncms installs, here is the code, it can be run from the command line $ php graphmigration.php (assuming saved in file called graphmigration.php)

<?php
$server   = "localhost";
$database = "emoncms";
$username = "root";
$password = "pass";
$port     = "3306";

$mysqli = @new mysqli($server,$username,$password,$database,$port);

$allgraphs = array();

$result = $mysqli->query("SELECT * FROM graph");
while ($row = $result->fetch_object()) $allgraphs[] = $row;

$result = $mysqli->query("DROP TABLE graph");
$result = $mysqli->query("CREATE TABLE graph (`id` int(11) not null auto_increment primary key, `userid` int(11), `data` text) ENGINE=MYISAM");

foreach ($allgraphs as $user) { 
    $userid = $user->userid;
    foreach (json_decode($user->savedgraphs) as $graph) {
        print $userid." ".$graph->name." ";
        
        $stmt = $mysqli->prepare("INSERT INTO graph ( userid, data ) VALUES (?,?)");
        $stmt->bind_param("is", $userid, json_encode($graph));
        $stmt->execute();
        $id = $mysqli->insert_id;
        
        print $id."\n";
    }
}

That’s good news :slight_smile:

Does that mean that viewing a dashboard without logging in, using the read-only apikey will also work too?

installed the new graph modle and made a new graph, only had one in test, not going to fiddle with the upgrade script.
One little ‘bug’ I see already. When making a graph with ‘feed tag’ unchecked and saved, on the page where you insert the graph, the tag is showed. Sorry for the large image but you see the two screens side by side (realtime screenshot)

Yes, I’m seeing this too. The embedded graph’s are not respecting the tag show/not show, only when you reopen the graph on the graphs page is the tag setting applied.

Also I’ve noticed the “fill” seems to impose a “zero” minimum Y-axis setting if left to “auto”, in this first pic the Y-axis min is auto and in the second, all I have done is selected “fill” for cpu_min, nothing else. This behavior is overridden by setting a specific Y-axis minimum, as seen in the third pic.

I have just found this fantastic new tool for definig graphs! Very nice!

But I am having the same problem that the feed tag is always shown when the graph is used somewhere.

Another thing that is a bit overkill IMO is showing a 14 digit value in the tooltip (but no unit :frowning: ). On the other hand, it would be nice if seconds could be shown (not only hours:minutes). And the year is truncated to 20 (instead of 2016) for me, not sure if you also see that.

Best regards, Jörg.

I have also noted that when accessing the graphs page from the feeds page by clicking the view icon next to a feed, the feed is displayed but the tick box in the lefthand panel is not ticked.

This makes locating the currently displayed feed quite tricky, because of the use of tags and shorter, duplicated feed names, it is really difficult to determine which “Grid power” you are using when there are 15 of them on one site, especially as the list on the left appears quite randomly (un)sorted (I suspect it’s in feedid order but haven’t checked yet).

To add to the confusion, when accessing from the feeds page as described, the tag is always “undefined”, hence the need to hunt out the displayed feed and deselect it and reselect it to get the tag populated correctly.

This unfortunately means the power and features of the graph module are somewhat undermined as I have to choose between trying to correctly select multiple feeds from an unsorted list or access only one feed at a time from the feeds page.

@TrystanLea - I would love to help out by debugging this for you, but as php is not a strong point for me and the code comments are few and far between, I have little or no hope of understanding the code. If you could add more comments we/I could probably figure some of this out and submit fixes for your review. I really would prefer to spend time helping out with debugging than renaming all my feeds, again.

Two other things:

  • if you add feeds with the right checkbox ('right Y axis) then the name is always ‘undefined’ or ‘undefined:undiefined’ if tag is shown. It is ok when you first click the left checkbox and then change to the right
  • the color bars shown below the graph for the individual feeds is always black although the graphs are shown in their default color when added

Yes. it would be a nice touch if that could be fixed, but since it’s always been the same in multigraph, I get the impression it’s not easily fixed.

The “undefined when using right tickbox” is a work-in-progress, previously the RH series was always “undefined”, now we can at least go left then right as a workaround.

Im loving the new graphing module but am having great fun and games finding my feeds (probably my fault for the way im using it) they are all in a long list as the should be but due to the way i have named feeds using the Tags to separate them i have 6 feeds called L1 Irms 6feeds called L2 Rms etc.

Is there any way it could be implemented as in feeds tht if you set the tg it groups the feeds together. This way i would see server 1 followed by its measurements. then server 2 etc…

Thanks in Advance
Dafydd

Yep, this is also an issue on the android app

it would be really good to get the tags utilized across the whole project, otherwise it’s pointless using them at all if we have to include the tag within the feed name as well.

Glad to say the graph module does now group feeds by tag with the option to minimise and maximise tag groups.

The starting feed not being selected has also been fixed as well as the starting feed name and tag in the feed list.

2 Likes

Hi

I have just started to use graphs. The first one I set up has the feed tag unchecked and in graph setup it displays OK without the feed tag showing. However in my dashboard the same graph shows the feed tag in the legend.

Ian

Pulled in these changes at last, the collapsing menu of feeds is much much better :smile:

You are right, this is a known issue, I think it’s mentioned earlier in this thread somewhere, but worth a bump! .

These graphs are looking great, is there any way i can generate a URL to show just the graph ether as an image or simple page just showing the graph after i have saved the name. I use openhab2 dashboards and can insert an image or url in a window and would like to have my power and solar in that dashboard with other things.

thanks

shane

@Shane_Kuzmanic I’ve made a couple of small changes to the graph module so that its easier to find the graph id to use in the url. You can pull in the changes with an emonpi update.

You will then see the selected graph id displayed below the graph name:

The URL to view a graph is:

https://emoncms.org/graph/embed?graphid=3042