mirror of
https://github.com/grafana/grafana.git
synced 2025-02-03 12:11:09 -06:00
Calcs: Update diff percent to be a percent (#90533)
diff per unexpected results
This commit is contained in:
parent
d0eaf4e484
commit
5e21898294
@ -55,13 +55,14 @@ describe('Stats Calculators', () => {
|
||||
it('should calculate basic stats', () => {
|
||||
const stats = reduceField({
|
||||
field: basicTable.fields[0],
|
||||
reducers: [ReducerID.first, ReducerID.last, ReducerID.mean, ReducerID.count],
|
||||
reducers: [ReducerID.first, ReducerID.last, ReducerID.mean, ReducerID.count, ReducerID.diffperc],
|
||||
});
|
||||
|
||||
expect(stats.first).toEqual(10);
|
||||
expect(stats.last).toEqual(20);
|
||||
expect(stats.mean).toEqual(15);
|
||||
expect(stats.count).toEqual(2);
|
||||
expect(stats.diffperc).toEqual(100);
|
||||
});
|
||||
|
||||
it('should handle undefined field data without crashing', () => {
|
||||
|
@ -573,7 +573,7 @@ export function doStandardCalcs(field: Field, ignoreNulls: boolean, nullAsZero:
|
||||
}
|
||||
|
||||
if (isNumber(calcs.firstNotNull) && isNumber(calcs.diff)) {
|
||||
calcs.diffperc = calcs.diff / calcs.firstNotNull;
|
||||
calcs.diffperc = (calcs.diff / calcs.firstNotNull) * 100;
|
||||
}
|
||||
return calcs;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user