From 60f1ae3745f53d2ee6c24e2ce572d0b6d9efa438 Mon Sep 17 00:00:00 2001 From: "Michael S. Molina" Date: Tue, 26 Oct 2021 10:55:32 -0300 Subject: [PATCH] feat: adds the option to show values for mixed time-series --- .../src/MixedTimeseries/controlPanel.tsx | 13 +++++++++++++ .../src/MixedTimeseries/transformProps.ts | 9 ++++++--- .../src/MixedTimeseries/types.ts | 4 ++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/plugins/plugin-chart-echarts/src/MixedTimeseries/controlPanel.tsx b/plugins/plugin-chart-echarts/src/MixedTimeseries/controlPanel.tsx index e79ae52da4..e2ce780f3c 100644 --- a/plugins/plugin-chart-echarts/src/MixedTimeseries/controlPanel.tsx +++ b/plugins/plugin-chart-echarts/src/MixedTimeseries/controlPanel.tsx @@ -42,6 +42,7 @@ const { orderDesc, rowLimit, seriesType, + showValues, stack, truncateYAxis, yAxisBounds, @@ -165,6 +166,18 @@ function createCustomizeSection(label: string, controlSuffix: string): ControlSe }, }, ], + [ + { + name: `show_value${controlSuffix}`, + config: { + type: 'CheckboxControl', + label: t('Show Values'), + renderTrigger: true, + default: showValues, + description: t('Whether to display the numerical values within the cells'), + }, + }, + ], [ { name: `opacity${controlSuffix}`, diff --git a/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts b/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts index 10371b5904..4303199573 100644 --- a/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts +++ b/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts @@ -34,7 +34,7 @@ import { EchartsMixedTimeseriesFormData, EchartsMixedTimeseriesChartTransformedProps, } from './types'; -import { ForecastSeriesEnum, ProphetValue } from '../types'; +import { ForecastSeriesEnum } from '../types'; import { parseYAxisBound } from '../utils/controls'; import { currentSeries, @@ -91,6 +91,8 @@ export default function transformProps( seriesType, seriesTypeB, showLegend, + showValue, + showValueB, stack, stackB, truncateYAxis, @@ -149,6 +151,7 @@ export default function transformProps( markerSize, areaOpacity: opacity, seriesType, + showValue, stack, yAxisIndex, filterState, @@ -162,6 +165,7 @@ export default function transformProps( markerSize: markerSizeB, areaOpacity: opacityB, seriesType: seriesTypeB, + showValue: showValueB, stack: stackB, yAxisIndex: yAxisIndexB, filterState, @@ -281,8 +285,7 @@ export default function transformProps( const prophetValue = !richTooltip ? [params] : params; const rows: Array = [`${tooltipTimeFormatter(value)}`]; - const prophetValues: Record = - extractProphetValuesFromTooltipParams(prophetValue); + const prophetValues = extractProphetValuesFromTooltipParams(prophetValue); Object.keys(prophetValues).forEach(key => { const value = prophetValues[key]; diff --git a/plugins/plugin-chart-echarts/src/MixedTimeseries/types.ts b/plugins/plugin-chart-echarts/src/MixedTimeseries/types.ts index 42f0585c23..e78c2c7f73 100644 --- a/plugins/plugin-chart-echarts/src/MixedTimeseries/types.ts +++ b/plugins/plugin-chart-echarts/src/MixedTimeseries/types.ts @@ -77,6 +77,8 @@ export type EchartsMixedTimeseriesFormData = QueryFormData & { rowLimitB: number; seriesType: EchartsTimeseriesSeriesType; seriesTypeB: EchartsTimeseriesSeriesType; + showValue: boolean; + showValueB: boolean; stack: boolean; stackB: boolean; yAxisIndex?: number; @@ -117,6 +119,8 @@ export const DEFAULT_FORM_DATA: EchartsMixedTimeseriesFormData = { rowLimitB: TIMESERIES_DEFAULTS.rowLimit, seriesType: TIMESERIES_DEFAULTS.seriesType, seriesTypeB: TIMESERIES_DEFAULTS.seriesType, + showValue: TIMESERIES_DEFAULTS.showValue, + showValueB: TIMESERIES_DEFAULTS.showValue, stack: TIMESERIES_DEFAULTS.stack, stackB: TIMESERIES_DEFAULTS.stack, yAxisIndex: 0,