vjymisal0 opened a new pull request, #42882:
URL: https://github.com/apache/superset/pull/42882

   ### SUMMARY
   
   On a stacked Timeseries Bar chart (`echarts_timeseries_bar`) with multiple 
metrics/series and "Show Value" enabled (not "Only Total"), a series whose 
value is exactly `0` for a given x-axis category still gets a visible value 
label, rendered at the same pixel position as the label of the segment directly 
below it — a zero-height stacked segment starts and ends at the same 
y-coordinate as the top of the previous segment, so the two labels overlap into 
unreadable, doubled text.
   
   Root cause, in the per-series `label.formatter` in 
`Timeseries/transformers.ts`: the label is shown when `numericValue >= 
thresholdValues[dataIndex]`. `thresholdValues[dataIndex]` comes from 
`((percentageThreshold || 0) / 100) * values` in `extractDataTotalValues`, so 
under the default `percentage_threshold: 0` it's `0` for every row — and `0 >= 
0` is true, so a segment with literally no height still gets a label.
   
   Fix: require the value to be strictly positive before showing a per-series 
stacked label, independent of the configured threshold. A zero-height segment 
has no meaningful position to attach a label to regardless of threshold 
settings.
   
   Related to, but distinct from, #42701 (which is about the "Only Total" sum 
being wrong rather than per-series label overlap) — I opened a separate PR 
(#42881) for that one since the two bugs are in different functions with 
independent fixes.
   
   Closes #42702
   
   ### TESTING INSTRUCTIONS
   
   Added `does not render a per-series stacked label for a zero-value segment 
(#42702)` to `test/Timeseries/transformers.test.ts`'s `transformSeries` suite, 
exercising the `label.formatter` directly: asserts an empty string for a `0` 
value and the formatted string for a non-zero one, with `thresholdValues: [0]` 
to match the default `percentage_threshold`.
   
   Ran locally:
   ```
   npx jest plugins/plugin-chart-echarts/test/Timeseries
   npx oxlint --config oxlint.json --quiet <changed files>
   ```
   240 tests pass, oxlint clean.
   
   Manual repro steps are in the linked issue (stacked bar chart, 2 metrics 
where one is 0 for a category, Show Value on, Only Total off).
   
   ### ADDITIONAL INFORMATION
   - [x] Has associated issue: #42702
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API


-- 
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]

Reply via email to