Stacked visualization: bug?

EmonCMS v8.2.6 on a local Raspberry running since mid-June 2014

I use in one of my dashboard the stacked visualization module. It could be useful to display min and max value as an example. But it seems to be buggy.

I have only 2 months visible in the global view: the current and the next one. I can't see June and July. In this example you can see that the value for September 2014 seems to be non null. And for August it seems that there are more than 2 bargraphs.

When I click on August all is ok. I reach the detail of the ongoing month.

When I click on September the graph is empty and it's normal.

I have this issue since the beginning. Am I the only one with this issue?

Olivier's picture

Re: Stacked visualization: bug?

Got it works like I imagine it should works: month value equal the total of all the day in the month. Just a comment in my post above the min max temperature was not the good example. This module coul be used to see the consumption by month and visualize detail by day.

The "issue" is coming from the function get_months(data) located in the /emoncms/Modules/vis/visualisations/common/daysmonthsyears.js file.

I don't know if this function is used in another module.

Here are the modifications:

function get_months(data)
{
   var gdata = [];
   gdata.data = [];
   gdata.days =[];

   var sum=0, s=0, i=0;
   var lmonth=0,month=0,year=0;
//   var tmp = []
   var d = new Date();

   for (var z in data)
   {
  lmonth = month;
  d.setTime(data[z][0]);
  month = d.getMonth();
  year = d.getFullYear();

    if (month!=lmonth && z!=0)
  {
    var tmp = [];
    tmp[0] = Date.UTC(year,month-1,1);
    tmp[1] = sum; ///daysInMonth(month-1, year);

    gdata.data[i] = tmp;
    gdata.days[i] = s;
    i++;
    sum = 0; s = 0;
  }
  sum += parseFloat(data[z][1]);
  s++;
    }

   var tmp = [];
   tmp[0] = Date.UTC(year,month,1);
   tmp[1] = sum; ///daysInMonth(month, year);

   gdata.data[i] = tmp;
   gdata.days[i] = s

   return gdata;
}

 

The result in my case:

 

Other remark: I'm not sure that the unit kWh/d is relevant. For me kWh is enough.

In fact it's easy to modify this in the $("#graph").bind("plothover", function (event, pos, item)

Olivier's picture

Re: Stacked visualization: bug?

I have investigated a little bit more.

The function "get_months(data)" is unchanged since 2012 and is used in 2 different visualizations module stacked.php and stackedsolar.php (arrived later in the project).

Is someone using one of this 2 visualizations or both and satisfied by the result obtained? If yes I can create a new function and use it as a replacement in the stacked.php module.

@Trystan: what do you think about this?

Olivier's picture

Re: Stacked visualization: bug?

Small update:

The function get_months_year() is also impacted because in it there is a call to get_months().

 

So in consequence, the following visualization modules are also impacted:

dailyhistogram.php

zoom.php

 

gloorung's picture

Re: Stacked visualization: bug?

I think this is related to one of my previous posts. I seems to be related to the fix for issue #213 (see https://github.com/emoncms/emoncms/pull/213 for more information). If I don't apply the fix for issue #213 (ie commit 1aecabfae929cbf55e37a94f875ae0c402473523), the problem does not appear.

Could you check if that solves your problem ?

 

Olivier's picture

Re: Stacked visualization: bug?

I think that it's not linked, it's not mysqltimeseries feeds and I don't have this update applied.

ggrich's picture

Re: Stacked visualization: bug?

I too have something similar.  Using Emoncms v8.4.0 since Dec of which I see your changes were included.

For example, when I hover over the bar graph for a certain month, it show the data for the previous month, and when I click that bargraph it shows the daily data for the previous month.

Is this related?

I also agree, would be nice if the units were selectable (kWh, hWh/d, $ etc)

 

Comment viewing options

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