mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
StatPanel: Fixes BizChart error max: yyy should not be less than min zzz (#28587)
This commit is contained in:
parent
5cded1d2cd
commit
0d803613d6
@ -11,14 +11,14 @@ import { MutableDataFrame, toDataFrame } from '../dataframe';
|
||||
import {
|
||||
DataFrame,
|
||||
Field,
|
||||
FieldColorModeId,
|
||||
FieldConfig,
|
||||
FieldConfigPropertyItem,
|
||||
FieldConfigSource,
|
||||
FieldType,
|
||||
InterpolateFunction,
|
||||
ThresholdsMode,
|
||||
FieldColorModeId,
|
||||
ScopedVars,
|
||||
ThresholdsMode,
|
||||
} from '../types';
|
||||
import { locationUtil, Registry } from '../utils';
|
||||
import { mockStandardProperties } from '../utils/tests/mockStandardProperties';
|
||||
@ -87,6 +87,21 @@ describe('Global MinMax', () => {
|
||||
expect(minmax.min).toEqual(-20);
|
||||
expect(minmax.max).toEqual(1234);
|
||||
});
|
||||
|
||||
describe('when value is null', () => {
|
||||
it('then global min max should be null', () => {
|
||||
const frame = toDataFrame({
|
||||
fields: [
|
||||
{ name: 'Time', type: FieldType.time, values: [1] },
|
||||
{ name: 'Value', type: FieldType.number, values: [null] },
|
||||
],
|
||||
});
|
||||
const { min, max } = findNumericFieldMinMax([frame]);
|
||||
|
||||
expect(min).toBeNull();
|
||||
expect(max).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('applyFieldOverrides', () => {
|
||||
|
@ -55,11 +55,23 @@ export function findNumericFieldMinMax(data: DataFrame[]): GlobalMinMax {
|
||||
for (const field of frame.fields) {
|
||||
if (field.type === FieldType.number) {
|
||||
const stats = reduceField({ field, reducers });
|
||||
if (stats[ReducerID.min] < min) {
|
||||
min = stats[ReducerID.min];
|
||||
const statsMin = stats[ReducerID.min];
|
||||
const statsMax = stats[ReducerID.max];
|
||||
|
||||
if (!statsMin) {
|
||||
min = statsMin;
|
||||
}
|
||||
if (stats[ReducerID.max] > max) {
|
||||
max = stats[ReducerID.max];
|
||||
|
||||
if (!statsMax) {
|
||||
max = statsMax;
|
||||
}
|
||||
|
||||
if (statsMin && statsMin < min) {
|
||||
min = statsMin;
|
||||
}
|
||||
|
||||
if (statsMax && statsMax > max) {
|
||||
max = statsMax;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user