mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Singlestat: Fixed issue with mapping null to text (#19689)
This commit is contained in:
parent
b858a5f496
commit
22fbaa7ac8
@ -116,11 +116,11 @@ describe('Stats Calculators', () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
data: [null, null, null], // All null
|
data: [null, null, null], // All null
|
||||||
result: undefined,
|
result: null,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
data: [undefined, undefined, undefined], // Empty row
|
data: [undefined, undefined, undefined], // Empty row
|
||||||
result: undefined,
|
result: null,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -236,8 +236,8 @@ function doStandardCalcs(field: Field, ignoreNulls: boolean, nullAsZero: boolean
|
|||||||
mean: null,
|
mean: null,
|
||||||
last: null,
|
last: null,
|
||||||
first: null,
|
first: null,
|
||||||
lastNotNull: undefined,
|
lastNotNull: null,
|
||||||
firstNotNull: undefined,
|
firstNotNull: null,
|
||||||
count: 0,
|
count: 0,
|
||||||
nonNullCount: 0,
|
nonNullCount: 0,
|
||||||
allIsNull: true,
|
allIsNull: true,
|
||||||
@ -272,8 +272,8 @@ function doStandardCalcs(field: Field, ignoreNulls: boolean, nullAsZero: boolean
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentValue !== null) {
|
if (currentValue !== null && currentValue !== undefined) {
|
||||||
const isFirst = calcs.firstNotNull === undefined;
|
const isFirst = calcs.firstNotNull === null;
|
||||||
if (isFirst) {
|
if (isFirst) {
|
||||||
calcs.firstNotNull = currentValue;
|
calcs.firstNotNull = currentValue;
|
||||||
}
|
}
|
||||||
@ -366,11 +366,11 @@ function calculateFirstNotNull(field: Field, ignoreNulls: boolean, nullAsZero: b
|
|||||||
const data = field.values;
|
const data = field.values;
|
||||||
for (let idx = 0; idx < data.length; idx++) {
|
for (let idx = 0; idx < data.length; idx++) {
|
||||||
const v = data.get(idx);
|
const v = data.get(idx);
|
||||||
if (v != null) {
|
if (v != null && v !== undefined) {
|
||||||
return { firstNotNull: v };
|
return { firstNotNull: v };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { firstNotNull: undefined };
|
return { firstNotNull: null };
|
||||||
}
|
}
|
||||||
|
|
||||||
function calculateLast(field: Field, ignoreNulls: boolean, nullAsZero: boolean): FieldCalcs {
|
function calculateLast(field: Field, ignoreNulls: boolean, nullAsZero: boolean): FieldCalcs {
|
||||||
@ -383,11 +383,11 @@ function calculateLastNotNull(field: Field, ignoreNulls: boolean, nullAsZero: bo
|
|||||||
let idx = data.length - 1;
|
let idx = data.length - 1;
|
||||||
while (idx >= 0) {
|
while (idx >= 0) {
|
||||||
const v = data.get(idx--);
|
const v = data.get(idx--);
|
||||||
if (v != null) {
|
if (v != null && v !== undefined) {
|
||||||
return { lastNotNull: v };
|
return { lastNotNull: v };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { lastNotNull: undefined };
|
return { lastNotNull: null };
|
||||||
}
|
}
|
||||||
|
|
||||||
function calculateChangeCount(field: Field, ignoreNulls: boolean, nullAsZero: boolean): FieldCalcs {
|
function calculateChangeCount(field: Field, ignoreNulls: boolean, nullAsZero: boolean): FieldCalcs {
|
||||||
|
Loading…
Reference in New Issue
Block a user