From fe2c14ff3acad11bf0f6a7b6544dfc52a6612152 Mon Sep 17 00:00:00 2001 From: Kamil Gabryjelski Date: Mon, 10 Jul 2023 18:04:38 +0200 Subject: [PATCH] fix: Ensure metrics is an array in Mixed Chart (#24643) --- .../src/MixedTimeseries/transformProps.ts | 4 ++-- superset/examples/birth_names.py | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) 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 a3028bfef8d38..331ddf190c59a 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts @@ -223,13 +223,13 @@ export default function transformProps( contributionMode ? ',.0%' : yAxisFormatSecondary, ); const customFormatters = buildCustomFormatters( - [...metrics, ...metricsB], + [...ensureIsArray(metrics), ...ensureIsArray(metricsB)], currencyFormats, columnFormats, yAxisFormat, ); const customFormattersSecondary = buildCustomFormatters( - [...metrics, ...metricsB], + [...ensureIsArray(metrics), ...ensureIsArray(metricsB)], currencyFormats, columnFormats, yAxisFormatSecondary, diff --git a/superset/examples/birth_names.py b/superset/examples/birth_names.py index 8b09aa4bf224a..f9bbf8a79bc60 100644 --- a/superset/examples/birth_names.py +++ b/superset/examples/birth_names.py @@ -392,14 +392,16 @@ def create_slices(tbl: SqlaTable) -> tuple[list[Slice], list[Slice]]: params=get_slice_json( defaults, viz_type="mixed_timeseries", - metrics={ - "expressionType": "SIMPLE", - "column": {"column_name": "num", "type": "BIGINT(20)"}, - "aggregate": "AVG", - "label": "AVG(num)", - "optionName": "metric_vgops097wej_g8uff99zhk7", - }, - metrics_b="sum__num", + metrics=[ + { + "expressionType": "SIMPLE", + "column": {"column_name": "num", "type": "BIGINT(20)"}, + "aggregate": "AVG", + "label": "AVG(num)", + "optionName": "metric_vgops097wej_g8uff99zhk7", + } + ], + metrics_b=["sum__num"], granularity_sqla="ds", yAxisIndex=0, yAxisIndexB=1,