StatPanels: Add new calculation option for percentage difference (#26369)

* Update fieldReducer.ts

addition of percentage difference to the singlestat panel

* Update time_series2.ts

* Update module.ts

* Update calculations-list.md

* Update docs/sources/panels/calculations-list.md

Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>

* Update public/app/plugins/panel/singlestat/module.ts

Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>

* Update module.ts

* Update calculations-list.md

* Update calculations-list.md

* Update module.ts

* Update fieldReducer.ts

* Update fieldReducer.ts

* Update fieldReducer.test.ts

* change name to remove wildcard characters

* Update calculations-list.md

* Update time_series2.ts

Fix spelling

* Update module.ts

* Update fieldReducer.ts

* formatting

* Update fieldReducer.ts

* Update fieldReducer.test.ts

* Update fieldReducer.test.ts

Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
This commit is contained in:
jedstar
2020-11-04 19:19:23 +10:00
committed by GitHub
parent 38bd6dd153
commit 77f6c241b1
5 changed files with 17 additions and 1 deletions

View File

@@ -232,6 +232,7 @@ export default class TimeSeries {
this.stats.first = null;
this.stats.delta = 0;
this.stats.diff = null;
this.stats.diffperc = 0;
this.stats.range = null;
this.stats.timeStep = Number.MAX_VALUE;
this.allIsNull = true;
@@ -336,6 +337,7 @@ export default class TimeSeries {
}
if (this.stats.current !== null && this.stats.first !== null) {
this.stats.diff = this.stats.current - this.stats.first;
this.stats.diffperc = this.stats.diff / this.stats.first;
}
this.stats.count = result.length;

View File

@@ -68,6 +68,7 @@ class SingleStatCtrl extends MetricsPanelCtrl {
{ value: 'first', text: 'First' },
{ value: 'delta', text: 'Delta' },
{ value: 'diff', text: 'Difference' },
{ value: 'diffperc', text: 'Difference percent' },
{ value: 'range', text: 'Range' },
{ value: 'last_time', text: 'Time of last point' },
];