Stacked "Only Total" still includes the sort-only metric on time-comparison charts (follow-up to #42881)

Aperta Adatta ai principianti
#43,068 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@waterWang ci sta già lavorando.

Dal 11/8/2026.

  • #43071 di @waterWang — aperta
  • #43116 di @SaadAhmed7 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
typescript

Direzione di ricerca

Inizia in superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts, all'interno di extractDataTotalValues, quindi segui il flusso citato attraverso Timeseries/buildQuery.ts, getMetricOffsetsMap e timeComparePivotOperator. Aggiungi una copertura di regressione per una metrica di confronto temporale usata solo per l'ordinamento e verifica che il totale impilato e il limite della soglia contino solo le serie visualizzate, incluse le colonne derivate.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

viz:charts:timeseries
Bug description

#42881 fixed the stacked "Only Total" label so it no longer includes a sort-only metric (timeseries_limit_metric). It handles the plain and verbose-named cases, but the exclusion is an exact-name match, so time-comparison derived columns of that same sort-only metric are still summed into the total.

On master, extractDataTotalValues in superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts:

const excludedKeys = new Set([xAxisCol, ...(extraMetricLabels ?? [])]);
...
if (excludedKeys.has(curr)) {
  return prev;
}

excludedKeys holds SortMetric, so a column named SortMetric__1 year ago does not match and is added to the stacked total.

That column is reachable on any time-comparison chart that also uses a sort-only metric:

  1. Timeseries/buildQuery.ts adds the extra metric into the query — metrics: [...(baseQueryObject.metrics || []), ...extra_metrics]
  2. getMetricOffsetsMap builds an offset key per query metric — [metric, offset].join(TIME_COMPARISON_SEPARATOR), i.e. SortMetric__1 year ago
  3. timeComparePivotOperator pivots both the base and offset keys into the result
  4. extractDataTotalValues sees the offset column, doesn't match it against excludedKeys, and includes it

The same inflated total also feeds thresholdValues, so the percentage-threshold cutoff for hiding small labels is off by the same amount.

How to reproduce
  1. Create a Timeseries Bar chart with two metrics, Stacked, Only Total enabled
  2. Set Sort By to a metric that is not among the displayed metrics
  3. Enable a Time Comparison offset (e.g. 1 year ago)
  4. The total label above each bar exceeds the visible stack height
Expected results

The total should count only the displayed stacked series, matching the bar height, as it now does without a time offset.

Actual results

The total is inflated by the value of the sort-only metric's time-shifted column.

Environment
  • Superset version: master (as of #42881)
  • Browser: any
Possible fix

Match derived forms as well as the exact label, e.g. treating a key as excluded when it equals an extra metric label or begins with <label>__ (TIME_COMPARISON_SEPARATOR). Worth keeping the boundary tight so a distinct metric that merely shares a prefix — SortTotal vs Sort — is still counted.

Happy to open a PR with a fix and tests if that sounds right.

Lingua principale
Python
Stelle
75.6k
Fork
18.6k
Merge medio
4g 2h
PR unite (30g)
469

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/superset

Tutte le issue di apache/superset

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.