VizGrimoire / VizGrimoireJS-lib

VizGrimoireJS Library
GNU General Public License v3.0
4 stars 8 forks source link

Error when producing % of increase or decrease in microdashboards #3

Closed dicortazar closed 11 years ago

dicortazar commented 11 years ago

https://github.com/VizGrimoire/VizGrimoireJS-lib/blob/master/src/Report.js#L342

dicortazar commented 11 years ago

Still failing, following the code: value = 100 value2 = 110 old_value = value2 - value = 110 - 100 = 10 var inc = parseInt(((value-old_value)/old_value)_100,null); inc = (((100 -10)/10)_100) = 900

The formula should be as follows:

if (value2 < value) {inc = parseInt(100 - ((value2/value)_100), null);} else {inc = parseInt(((value2/value)_100) - 100, null);}

acs commented 11 years ago

If value2 is 110, then the old_value is 10 and the new value is 100 and the % of inc relative to the old value is 900. I think it is right no?

dicortazar commented 11 years ago

nop, the increment or decrement in that case is a 10%.

dicortazar commented 11 years ago

Ok, it seems that it's fixed by now.

I wrongly assumed that value was the number for the first period and value2 the numbers for the previous period. However, value is the number for the first period, and value2 the aggregation of the number of the first period plus the second period.

Sorry for the noisy second part :)