From 3ae970c61358bf873f2d5bb8256bfc94b41f93c6 Mon Sep 17 00:00:00 2001 From: Antonio Rivero Date: Wed, 6 Jul 2022 14:10:07 -0300 Subject: [PATCH 1/3] Time Series Chart: -Apache echarts has this option as false by default for time axis, so we need to override it for our charts so it's uto determined and not fixed to hidden. - Add AxisType enum so we stop comparing agains raw strings when checking xAxis type --- .../src/Timeseries/transformProps.ts | 16 ++++++++++++++-- .../plugin-chart-echarts/src/Timeseries/types.ts | 7 +++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts index ba651a60da394..f309ae8295d5f 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts @@ -35,12 +35,14 @@ import { import { isDerivedSeries } from '@superset-ui/chart-controls'; import { EChartsCoreOption, SeriesOption } from 'echarts'; import { ZRLineType } from 'echarts/types/src/util/types'; +import { merge } from 'lodash'; import { EchartsTimeseriesChartProps, EchartsTimeseriesFormData, EchartsTimeseriesSeriesType, TimeseriesChartTransformedProps, OrientationType, + AxisType, } from './types'; import { DEFAULT_FORM_DATA } from './constants'; import { ForecastSeriesEnum, ForecastValue } from '../types'; @@ -329,13 +331,23 @@ export default function transformProps( rotate: xAxisLabelRotation, }, minInterval: - xAxisType === 'time' && timeGrainSqla + xAxisType === AxisType.time && timeGrainSqla ? TIMEGRAIN_TO_TIMESTAMP[timeGrainSqla] : 0, }; + + if (xAxisType === AxisType.time) { + /** + * Overriding default behavior (false) for time axis regardless of the granilarity. + * Not including this in the initial declaration above so if echarts changes the default + * behavior for other axist types we won't unintentionally override it + */ + xAxis = merge(xAxis, { axisLabel: { showMaxLabel: null } }); + } + let yAxis: any = { ...defaultYAxis, - type: logAxis ? 'log' : 'value', + type: logAxis ? AxisType.log : AxisType.value, min, max, minorTick: { show: true }, diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/types.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/types.ts index 946d41ec164d8..71729bd0f11d0 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/types.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/types.ts @@ -94,3 +94,10 @@ export interface EchartsTimeseriesChartProps export type TimeseriesChartTransformedProps = EChartTransformedProps; + +export enum AxisType { + category = 'category', + value = 'value', + time = 'time', + log = 'log', +} From 038e2ff34e9815a3f5eb1f9012323cc0cd6b0379 Mon Sep 17 00:00:00 2001 From: Antonio Rivero Date: Thu, 7 Jul 2022 09:17:13 -0300 Subject: [PATCH 2/3] Time Series Chart: - set the showMaxLabel option directly without using merge --- .../plugin-chart-echarts/src/Timeseries/transformProps.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts index f309ae8295d5f..7d6ea0b20c836 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts @@ -35,7 +35,6 @@ import { import { isDerivedSeries } from '@superset-ui/chart-controls'; import { EChartsCoreOption, SeriesOption } from 'echarts'; import { ZRLineType } from 'echarts/types/src/util/types'; -import { merge } from 'lodash'; import { EchartsTimeseriesChartProps, EchartsTimeseriesFormData, @@ -342,7 +341,7 @@ export default function transformProps( * Not including this in the initial declaration above so if echarts changes the default * behavior for other axist types we won't unintentionally override it */ - xAxis = merge(xAxis, { axisLabel: { showMaxLabel: null } }); + xAxis.axisLabel.showLabel = null; } let yAxis: any = { From 3169da916bd41d0001633f7004e8e0e0546237ab Mon Sep 17 00:00:00 2001 From: Antonio Rivero Date: Tue, 12 Jul 2022 09:56:03 -0300 Subject: [PATCH 3/3] Time Series Chart: - Rename the property to showMaxLabel as it was originally --- .../plugin-chart-echarts/src/Timeseries/transformProps.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts index 7d6ea0b20c836..533677b347ddd 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts @@ -341,7 +341,7 @@ export default function transformProps( * Not including this in the initial declaration above so if echarts changes the default * behavior for other axist types we won't unintentionally override it */ - xAxis.axisLabel.showLabel = null; + xAxis.axisLabel.showMaxLabel = null; } let yAxis: any = {