mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Timeline: Fixes crash when there was only 1 threshold step (#34471)
This commit is contained in:
parent
99acbdd3c5
commit
fd6e338651
@ -318,15 +318,14 @@ export function prepareTimelineLegendItems(
|
||||
}
|
||||
|
||||
const items: VizLegendItem[] = [];
|
||||
const first = fields[0].config;
|
||||
const colorMode = first.color?.mode ?? FieldColorModeId.Fixed;
|
||||
const fieldConfig = fields[0].config;
|
||||
const colorMode = fieldConfig.color?.mode ?? FieldColorModeId.Fixed;
|
||||
const thresholds = fieldConfig.thresholds;
|
||||
|
||||
// If thresholds are enabled show each step in the legend
|
||||
if (colorMode === FieldColorModeId.Thresholds && first.thresholds?.steps) {
|
||||
const steps = first.thresholds.steps;
|
||||
const disp = getValueFormat(
|
||||
first.thresholds.mode === ThresholdsMode.Percentage ? 'percent' : first.unit ?? 'fixed'
|
||||
);
|
||||
if (colorMode === FieldColorModeId.Thresholds && thresholds?.steps && thresholds.steps.length > 1) {
|
||||
const steps = thresholds.steps;
|
||||
const disp = getValueFormat(thresholds.mode === ThresholdsMode.Percentage ? 'percent' : fieldConfig.unit ?? '');
|
||||
|
||||
const fmt = (v: number) => formattedValueToString(disp(v));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user