From 4a6c2e9276fc1e66e905962baf01988e3b8de0d4 Mon Sep 17 00:00:00 2001 From: stephenLYZ <750188453@qq.com> Date: Mon, 18 Apr 2022 23:55:22 +0800 Subject: [PATCH 1/3] fix(plugin-chart-echarts): [feature-parity] apply button of annotation layer does't work --- .../src/sections/annotationsAndLayers.tsx | 2 ++ .../src/MixedTimeseries/controlPanel.tsx | 18 +----------------- .../src/MixedTimeseries/transformProps.ts | 3 +-- .../src/Timeseries/transformProps.ts | 5 ++--- 4 files changed, 6 insertions(+), 22 deletions(-) diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/sections/annotationsAndLayers.tsx b/superset-frontend/packages/superset-ui-chart-controls/src/sections/annotationsAndLayers.tsx index 9fffbb578e4d1..6db4abad683ae 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/src/sections/annotationsAndLayers.tsx +++ b/superset-frontend/packages/superset-ui-chart-controls/src/sections/annotationsAndLayers.tsx @@ -24,6 +24,7 @@ export const annotationLayers = []; export const annotationsAndLayersControls: ControlPanelSectionConfig = { label: t('Annotations and Layers'), expanded: false, + tabOverride: 'data', controlSetRows: [ [ { @@ -33,6 +34,7 @@ export const annotationsAndLayersControls: ControlPanelSectionConfig = { label: '', default: annotationLayers, description: t('Annotation Layers'), + renderTrigger: true, }, }, ], diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/controlPanel.tsx index e39c023661696..29e2464302f98 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/controlPanel.tsx @@ -289,23 +289,7 @@ const config: ControlPanelConfig = { createAdvancedAnalyticsSection(t('Advanced analytics Query A'), ''), createQuerySection(t('Query B'), '_b'), createAdvancedAnalyticsSection(t('Advanced analytics Query B'), '_b'), - { - label: t('Annotations and Layers'), - expanded: false, - controlSetRows: [ - [ - { - name: 'annotation_layers', - config: { - type: 'AnnotationLayerControl', - label: '', - default: annotationLayers, - description: t('Annotation Layers'), - }, - }, - ], - ], - }, + sections.annotationsAndLayersControls, sections.titleControls, { label: t('Chart Options'), diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts index 10dd33ff1ac4e..139dcd9af70ce 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts @@ -81,9 +81,8 @@ export default function transformProps( filterState, datasource, theme, + annotationData = {}, } = chartProps; - const { annotation_data: annotationData_ } = queriesData[0]; - const annotationData = annotationData_ || {}; const { verboseMap = {} } = datasource; const data1 = (queriesData[0].data || []) as TimeseriesDataRecord[]; const data2 = (queriesData[1].data || []) as TimeseriesDataRecord[]; 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 87396c0015d7a..0b1041403e218 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts @@ -84,13 +84,12 @@ export default function transformProps( queriesData, datasource, theme, + annotationData = {}, } = chartProps; const { verboseMap = {} } = datasource; const [queryData] = queriesData; - const { annotation_data: annotationData_, data = [] } = - queryData as TimeseriesChartDataResponseResult; + const { data = [] } = queryData as TimeseriesChartDataResponseResult; const dataTypes = getColtypesMapping(queryData); - const annotationData = annotationData_ || {}; const { area, From 79ef081c2485751564290c0ef1755c7963de7d9f Mon Sep 17 00:00:00 2001 From: stephenLYZ <750188453@qq.com> Date: Tue, 19 Apr 2022 15:13:07 +0800 Subject: [PATCH 2/3] fix: lint --- .../plugin-chart-echarts/src/MixedTimeseries/controlPanel.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/controlPanel.tsx index 29e2464302f98..8566fa599921c 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/controlPanel.tsx @@ -35,7 +35,6 @@ import { legendSection, richTooltipSection, xAxisControl } from '../controls'; const { area, - annotationLayers, logAxis, markerEnabled, markerSize, From 116484a9af614c11f4d29d8d5dc81cbfbc10a929 Mon Sep 17 00:00:00 2001 From: stephenLYZ <750188453@qq.com> Date: Wed, 20 Apr 2022 15:22:43 +0800 Subject: [PATCH 3/3] fix: test --- .../test/Timeseries/transformProps.test.ts | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts b/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts index 3fbe72e59ad12..172ce24204218 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts @@ -180,54 +180,54 @@ describe('EchartsTimeseries transformProps', () => { ...formData, annotationLayers: [event, interval, timeseries], }, - queriesData: [ - { - ...queriesData[0], - annotation_data: { - 'My Event': { - columns: [ - 'start_dttm', - 'end_dttm', - 'short_descr', - 'long_descr', - 'json_metadata', - ], - records: [ - { - start_dttm: 0, - end_dttm: 1000, - short_descr: '', - long_descr: '', - json_metadata: null, - }, - ], + annotationData: { + 'My Event': { + columns: [ + 'start_dttm', + 'end_dttm', + 'short_descr', + 'long_descr', + 'json_metadata', + ], + records: [ + { + start_dttm: 0, + end_dttm: 1000, + short_descr: '', + long_descr: '', + json_metadata: null, }, - 'My Interval': { - columns: ['start', 'end', 'title'], - records: [ - { - start: 2000, - end: 3000, - title: 'My Title', - }, - ], + ], + }, + 'My Interval': { + columns: ['start', 'end', 'title'], + records: [ + { + start: 2000, + end: 3000, + title: 'My Title', }, - 'My Timeseries': [ + ], + }, + 'My Timeseries': [ + { + key: 'My Line', + values: [ + { + x: 10000, + y: 11000, + }, { - key: 'My Line', - values: [ - { - x: 10000, - y: 11000, - }, - { - x: 20000, - y: 21000, - }, - ], + x: 20000, + y: 21000, }, ], }, + ], + }, + queriesData: [ + { + ...queriesData[0], }, ], });