sadpandajoe commented on code in PR #43116:
URL: https://github.com/apache/superset/pull/43116#discussion_r4007789155
##########
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts:
##########
@@ -458,17 +459,31 @@ export default function transformProps(
// metric. extraMetricLabels must be mapped the same way, or a sort-only
// metric with a verbose_name set would silently fail to match here (and in
// extractSeries below, which has the same requirement).
- const extraMetricLabels = extractExtraMetrics(chartProps.rawFormData)
- .map(getMetricLabel)
- .map(label => verboseMap[label] ?? label);
+ const rawExtraMetricLabels = extractExtraMetrics(chartProps.rawFormData).map(
+ getMetricLabel,
+ );
+ const extraMetricLabels = rawExtraMetricLabels.map(
+ label => verboseMap[label] ?? label,
+ );
+ // Time comparison emits a derived column per query metric, and sort-only
+ // metrics are part of the query, so they get one too. These keep the *raw*
+ // metric label - rebaseForecastDatum only resolves the forecast context name
+ // through verboseMap, which never matches a `<label>__<offset>` key. Build
+ // the exact keys from the configured offsets rather than prefix-matching, so
+ // a displayed metric that merely looks like a derived one is still counted.
+ const extraMetricOffsetLabels = rawExtraMetricLabels.flatMap(label =>
+ ensureIsArray(chartProps.rawFormData?.time_compare).map(
+ offset => `${label}${TIME_COMPARISON_SEPARATOR}${offset}`,
Review Comment:
A displayed metric named literally `sort_metric__1 year ago` remains
rendered by `extractSeries`, but this synthetic exclusion removes it from
`totalStackedValues`, so the visible stack and its Only Total/percentage
threshold disagree. Could the exclusion be tied to sort-metric columns that the
query actually emits (or otherwise avoid colliding with valid metric labels)
and cover this case?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]