Closed dicortazar closed 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);}
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?
nop, the increment or decrement in that case is a 10%.
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 :)
https://github.com/VizGrimoire/VizGrimoireJS-lib/blob/master/src/Report.js#L342