krishn1301 opened a new pull request, #42855:
URL: https://github.com/apache/superset/pull/42855
### SUMMARY
Fixes #42701.
With **Stacked Style: Stack** and **Only Total** enabled, the total shown
above each bar included the sort metric. In the reported case, metrics `A = 32`
and `B = 0` with a `timeseries_limit_metric` of `2` displayed a total of **34**
instead of **32**.
`extractDataTotalValues` sums every numeric column in each row:
```ts
Object.keys(data).reduce((prev, curr) => { ... prev + data[curr] ... })
```
A sort metric is present in the query result but is never rendered as a
series, so it silently inflated the total — and the `thresholdValues` derived
from that total, which decides which labels are shown.
This threads the extra metric labels into `extractDataTotalValues` and skips
those columns when accumulating. The labels were already being computed in
`transformProps.ts` via `extractExtraMetrics(...).map(getMetricLabel)`; that
computation just happened *after* the `extractDataTotalValues` call, so it's
moved above and passed in. The new option is optional, so other callers of
`extractDataTotalValues` are unaffected.
### TESTING INSTRUCTIONS
```
cd superset-frontend
npm run test -- plugins/plugin-chart-echarts/test/utils/series.test.ts
```
Four tests were added under `extractDataTotalValues`, using the exact
numbers from the issue:
- excludes extra metrics from the stacked total — `A=32, B=0, Sort=2` gives
`[32]` (fails without this change)
- includes every metric when no `extraMetricLabels` are passed — the same
row gives `[34]`
- derives `thresholdValues` from the total excluding extra metrics (fails
without this change)
- respects `legendState` alongside the exclusion
Manually: build a Stacked Timeseries Bar chart with two metrics, set a
**Sort By** metric that differs from both, enable **Only Total**, and confirm
the total equals the sum of the visible segments.
### ADDITIONAL INFORMATION
- [x] Has associated issue: #42701
- [x] Changes UI
--
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]