mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: support empty/missing strings (#34027)
This commit is contained in:
parent
7bcb938b80
commit
17750d3cdb
@ -346,6 +346,11 @@ describe('Date display options', () => {
|
|||||||
theme: createTheme(),
|
theme: createTheme(),
|
||||||
});
|
});
|
||||||
expect(processor('22.1122334455').text).toEqual('22.11');
|
expect(processor('22.1122334455').text).toEqual('22.11');
|
||||||
|
|
||||||
|
// Support empty/missing strings
|
||||||
|
expect(processor(undefined).text).toEqual('');
|
||||||
|
expect(processor(null).text).toEqual('');
|
||||||
|
expect(processor('').text).toEqual('');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -137,6 +137,10 @@ export function getRawDisplayProcessor(): DisplayProcessor {
|
|||||||
function getDefaultColorFunc(field: Field, scaleFunc: ScaleCalculator, theme: GrafanaTheme2) {
|
function getDefaultColorFunc(field: Field, scaleFunc: ScaleCalculator, theme: GrafanaTheme2) {
|
||||||
if (field.type === FieldType.string) {
|
if (field.type === FieldType.string) {
|
||||||
return (value: any) => {
|
return (value: any) => {
|
||||||
|
if (!value) {
|
||||||
|
return { color: theme.colors.background.primary, percent: 0 };
|
||||||
|
}
|
||||||
|
|
||||||
const hc = strHashCode(value as string);
|
const hc = strHashCode(value as string);
|
||||||
return {
|
return {
|
||||||
color: classicColors[Math.floor(hc % classicColors.length)],
|
color: classicColors[Math.floor(hc % classicColors.length)],
|
||||||
|
Loading…
Reference in New Issue
Block a user