From 73a276107e3f35eb7b6e54c1dcee1366688652a4 Mon Sep 17 00:00:00 2001 From: ashgorithm Date: Wed, 29 Mar 2023 11:49:15 +0530 Subject: [PATCH 1/3] type for series in legacy word cloud plugin is incorrect --- .../src/legacyPlugin/transformProps.ts | 15 +++++++++++++-- .../src/legacyPlugin/types.ts | 4 ++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/superset-frontend/plugins/plugin-chart-word-cloud/src/legacyPlugin/transformProps.ts b/superset-frontend/plugins/plugin-chart-word-cloud/src/legacyPlugin/transformProps.ts index aec557d616d58..61f2359eec4d0 100644 --- a/superset-frontend/plugins/plugin-chart-word-cloud/src/legacyPlugin/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-word-cloud/src/legacyPlugin/transformProps.ts @@ -34,6 +34,16 @@ function getMetricLabel( return metric.label; } +function getSeriesLabel( + series: LegacyWordCloudFormData['series'], +): string | undefined { + if (typeof series === 'string' || typeof series === 'undefined') { + return series; + } + + return series.label; +} + export default function transformProps(chartProps: ChartProps): WordCloudProps { const { width, height, formData, queriesData } = chartProps; const { @@ -47,10 +57,11 @@ export default function transformProps(chartProps: ChartProps): WordCloudProps { } = formData as LegacyWordCloudFormData; const metricLabel = getMetricLabel(metric); + const seriesLabel = getSeriesLabel(series) || ''; const encoding: Partial = { color: { - field: series, + field: seriesLabel, scale: { scheme: colorScheme, }, @@ -68,7 +79,7 @@ export default function transformProps(chartProps: ChartProps): WordCloudProps { type: 'quantitative', }, text: { - field: series, + field: seriesLabel, }, }; diff --git a/superset-frontend/plugins/plugin-chart-word-cloud/src/legacyPlugin/types.ts b/superset-frontend/plugins/plugin-chart-word-cloud/src/legacyPlugin/types.ts index 6101d14a0f7e7..2cdc348126c3f 100644 --- a/superset-frontend/plugins/plugin-chart-word-cloud/src/legacyPlugin/types.ts +++ b/superset-frontend/plugins/plugin-chart-word-cloud/src/legacyPlugin/types.ts @@ -17,13 +17,13 @@ * under the License. */ -import { QueryFormData } from '@superset-ui/core'; +import { QueryFormColumn, QueryFormData } from '@superset-ui/core'; import { RotationType } from '../chart/WordCloud'; export type LegacyWordCloudFormData = QueryFormData & { colorScheme: string; rotation?: RotationType; - series: string; + series: QueryFormColumn; sizeFrom?: number; sizeTo: number; }; From dea60e3bb7f6529702a632f9456f61a0d31aea1c Mon Sep 17 00:00:00 2001 From: ashgorithm Date: Thu, 30 Mar 2023 11:51:52 +0530 Subject: [PATCH 2/3] used getColumnLabel util instead of writing new --- .../src/legacyPlugin/transformProps.ts | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/superset-frontend/plugins/plugin-chart-word-cloud/src/legacyPlugin/transformProps.ts b/superset-frontend/plugins/plugin-chart-word-cloud/src/legacyPlugin/transformProps.ts index 61f2359eec4d0..0b5a36b9999e2 100644 --- a/superset-frontend/plugins/plugin-chart-word-cloud/src/legacyPlugin/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-word-cloud/src/legacyPlugin/transformProps.ts @@ -17,7 +17,7 @@ * under the License. */ -import { ChartProps } from '@superset-ui/core'; +import { ChartProps, getColumnLabel } from '@superset-ui/core'; import { WordCloudProps, WordCloudEncoding } from '../chart/WordCloud'; import { LegacyWordCloudFormData } from './types'; @@ -34,16 +34,6 @@ function getMetricLabel( return metric.label; } -function getSeriesLabel( - series: LegacyWordCloudFormData['series'], -): string | undefined { - if (typeof series === 'string' || typeof series === 'undefined') { - return series; - } - - return series.label; -} - export default function transformProps(chartProps: ChartProps): WordCloudProps { const { width, height, formData, queriesData } = chartProps; const { @@ -57,7 +47,7 @@ export default function transformProps(chartProps: ChartProps): WordCloudProps { } = formData as LegacyWordCloudFormData; const metricLabel = getMetricLabel(metric); - const seriesLabel = getSeriesLabel(series) || ''; + const seriesLabel = getColumnLabel(series); const encoding: Partial = { color: { From 6e024743c58f928f5157146ddc214357420db844 Mon Sep 17 00:00:00 2001 From: ashgorithm Date: Thu, 30 Mar 2023 13:15:32 +0530 Subject: [PATCH 3/3] build fix for incompatible types --- .../plugins/plugin-chart-word-cloud/src/types.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/superset-frontend/plugins/plugin-chart-word-cloud/src/types.ts b/superset-frontend/plugins/plugin-chart-word-cloud/src/types.ts index 324db12778690..fef33bb56c105 100644 --- a/superset-frontend/plugins/plugin-chart-word-cloud/src/types.ts +++ b/superset-frontend/plugins/plugin-chart-word-cloud/src/types.ts @@ -17,12 +17,12 @@ * under the License. */ -import { QueryFormData } from '@superset-ui/core'; +import { QueryFormColumn, QueryFormData } from '@superset-ui/core'; import { WordCloudVisualProps } from './chart/WordCloud'; // FormData for wordcloud contains both common properties of all form data // and properties specific to wordcloud visualization export type WordCloudFormData = QueryFormData & WordCloudVisualProps & { - series: string; + series: QueryFormColumn; };