mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
@@ -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;
|
||||
|
||||
@@ -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' },
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user