This is an automated email from the ASF dual-hosted git repository. sadpandajoe pushed a commit to branch fix-matrixify-multi-chart-layout-2 in repository https://gitbox.apache.org/repos/asf/superset.git
commit b7945b81004b906c5e317db1f53d859d4dfcf742 Author: sadpandajoe <[email protected]> AuthorDate: Fri Sep 25 01:33:55 2026 +0000 fix(matrixify): apply metrics-axis selection to every query-specific metrics field generateCellFormData's metrics-axis override only ever wrote the primary `metrics`/`metric` fields, mirroring the fan-out that appendMatrixifyFilters already does for `adhoc_filters`/`adhoc_filters_*` (added in #43861) but never extending it to metrics. Multi-query viz types (currently only Mixed Chart, which combines multiple chart types in one panel) read each query's metrics from a separate suffixed field (`metrics_b`), so a cell's chosen metric never reached the secondary query - every cell rendered the same, unvarying secondary series regardless of which row/column it was in. overrideMatrixifyMetrics generalizes the override to `metrics` and every `metrics_*` field present on the formData, matching the existing `adhoc_filters_.+` fan-out pattern. Co-Authored-By: Claude Sonnet 5 <[email protected]> --- .../components/Matrixify/MatrixifyGridGenerator.ts | 34 ++++++++++++++++++---- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/superset-frontend/packages/superset-ui-core/src/chart/components/Matrixify/MatrixifyGridGenerator.ts b/superset-frontend/packages/superset-ui-core/src/chart/components/Matrixify/MatrixifyGridGenerator.ts index 900a3160deb..7a61ad9628e 100644 --- a/superset-frontend/packages/superset-ui-core/src/chart/components/Matrixify/MatrixifyGridGenerator.ts +++ b/superset-frontend/packages/superset-ui-core/src/chart/components/Matrixify/MatrixifyGridGenerator.ts @@ -18,7 +18,7 @@ */ import Handlebars from 'handlebars'; -import type { QueryFormData } from '../../../query'; +import type { AdhocMetric, QueryFormData } from '../../../query'; import type { AdhocFilter, BinaryAdhocFilter, @@ -134,6 +134,30 @@ function appendMatrixifyFilters( }); } +/** + * Apply the matrix's chosen metrics to the primary `metrics` collection as well + * as every query-specific `metrics_*` collection present on the formData (plus + * the singular `metric` field used by single-metric viz types). Charts with + * more than one query (e.g. Mixed Chart) read each query's metrics from a + * separate collection (`metrics_b`, `metrics_c`, ...), so a cell's chosen + * metrics must overwrite all of them, not just the primary query's. + */ +function overrideMatrixifyMetrics( + formData: QueryFormData & MatrixifyFormData, + metrics: AdhocMetric[], +): void { + const metricsFields: Record<string, unknown> = formData; + const metricsKeys = [ + 'metrics', + ...Object.keys(metricsFields).filter(key => /^metrics_.+$/u.test(key)), + ]; + + metricsKeys.forEach(key => { + metricsFields[key] = metrics; + }); + metricsFields.metric = metrics[0]; +} + /** * Generate form data for a specific grid cell */ @@ -205,7 +229,7 @@ function generateCellFormData( } // Set metrics based on row/column configuration - const metrics = []; + const metrics: AdhocMetric[] = []; if (rowConfig && rowIndex !== null && rowConfig.mode === 'metrics') { const metric = rowConfig.metrics?.[rowIndex]; @@ -221,10 +245,10 @@ function generateCellFormData( } } - // If we have metrics from the matrix, use them; otherwise keep original + // If we have metrics from the matrix, apply them to the primary and every + // query-specific metrics collection; otherwise keep each query's original. if (metrics.length > 0) { - cellFormData.metrics = metrics; - cellFormData.metric = metrics[0]; + overrideMatrixifyMetrics(cellFormData, metrics); } return cellFormData;
