From 8aedf8113371f933b8afcafe7a392641fda69f47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 20 May 2020 17:28:41 +0200 Subject: [PATCH] Graph: Legend decimals now work as expected (#24931) * Graph: Legend decimals now work as expected * removed new test that I could not get green --- .../grafana-data/src/valueFormats/valueFormats.test.ts | 1 + public/app/core/time_series2.ts | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/grafana-data/src/valueFormats/valueFormats.test.ts b/packages/grafana-data/src/valueFormats/valueFormats.test.ts index dff09f434a3..9b321a44a67 100644 --- a/packages/grafana-data/src/valueFormats/valueFormats.test.ts +++ b/packages/grafana-data/src/valueFormats/valueFormats.test.ts @@ -25,6 +25,7 @@ const formatTests: ValueFormatTest[] = [ { id: 'ms', decimals: 0, value: 1200, result: '1 s' }, { id: 'short', decimals: 0, scaledDecimals: -1, value: 98765, result: '98.77 K' }, { id: 'short', decimals: 0, scaledDecimals: 0, value: 9876543, result: '9.876543 Mil' }, + { id: 'short', decimals: 2, scaledDecimals: null, value: 9876543, result: '9.88 Mil' }, { id: 'kbytes', decimals: 3, value: 10000000, result: '9.537 GiB' }, { id: 'deckbytes', decimals: 3, value: 10000000, result: '10.000 GB' }, { id: 'megwatt', decimals: 3, value: 1000, result: '1.000 GW' }, diff --git a/public/app/core/time_series2.ts b/public/app/core/time_series2.ts index aa06d534db0..0c4b2415586 100644 --- a/public/app/core/time_series2.ts +++ b/public/app/core/time_series2.ts @@ -98,8 +98,8 @@ export default class TimeSeries { hideTooltip: boolean; allIsNull: boolean; allIsZero: boolean; - decimals: number; - scaledDecimals: number; + decimals: DecimalCount; + scaledDecimals: DecimalCount; hasMsResolution: boolean; isOutsideRange: boolean; @@ -344,8 +344,8 @@ export default class TimeSeries { updateLegendValues(formater: ValueFormatter, decimals: DecimalCount, scaledDecimals: DecimalCount) { this.valueFormater = formater; - this.decimals = decimals ?? 0; - this.scaledDecimals = scaledDecimals ?? 0; + this.decimals = decimals; + this.scaledDecimals = scaledDecimals; } formatValue(value: number) {