From 2a4dde5d89b0b49546072d80a634cc920bf72a51 Mon Sep 17 00:00:00 2001 From: Ville Brofeldt Date: Wed, 2 Feb 2022 12:55:33 +0200 Subject: [PATCH] check for DTTM_ALIAS --- .../plugins/plugin-chart-echarts/src/utils/forecast.ts | 9 +++++---- .../plugin-chart-echarts/test/utils/forecast.test.ts | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/utils/forecast.ts b/superset-frontend/plugins/plugin-chart-echarts/src/utils/forecast.ts index 528c27765ecb1..617aaa5f8c255 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/utils/forecast.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/utils/forecast.ts @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { DataRecord, NumberFormatter } from '@superset-ui/core'; +import { DataRecord, DTTM_ALIAS, NumberFormatter } from '@superset-ui/core'; import { CallbackDataParams, OptionName } from 'echarts/types/src/util/types'; import { TooltipMarker } from 'echarts/types/src/util/format'; import { @@ -119,9 +119,10 @@ export function rebaseForecastDatum( const newRow: DataRecord = {}; keys.forEach(key => { const forecastContext = extractForecastSeriesContext(key); - const verboseKey = verboseMap[forecastContext.name] - ? `${verboseMap[forecastContext.name]}${forecastContext.type}` - : key; + const verboseKey = + key !== DTTM_ALIAS && verboseMap[forecastContext.name] + ? `${verboseMap[forecastContext.name]}${forecastContext.type}` + : key; // check if key is equal to lower confidence level. If so, extract it // from the upper bound diff --git a/superset-frontend/plugins/plugin-chart-echarts/test/utils/forecast.test.ts b/superset-frontend/plugins/plugin-chart-echarts/test/utils/forecast.test.ts index 2743d828db09b..819b2b85b137e 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/test/utils/forecast.test.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/test/utils/forecast.test.ts @@ -103,7 +103,7 @@ describe('rebaseForecastDatum', () => { ]); }); - it('should rename all series based on verboseMap', () => { + it('should rename all series based on verboseMap but leave __timestamp alone', () => { expect( rebaseForecastDatum( [ @@ -128,6 +128,7 @@ describe('rebaseForecastDatum', () => { ], { abc: 'Abracadabra', + __timestamp: 'Time', }, ), ).toEqual([