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

   ### SUMMARY
   
   Fixes #42702.
   
   On a stacked timeseries bar chart, a series whose value is `0` occupies no 
vertical space, but its value label was still rendered — landing on top of the 
label of the segment next to it.
   
   The root cause is a falsy check, not the label logic itself. In 
`transformSeries`:
   
   ```ts
   numericValue >= (thresholdValues[dataIndex] || Number.MIN_SAFE_INTEGER)
   ```
   
   When `percentage_threshold` is `0` (the default), 
`thresholdValues[dataIndex]` is `0`, which is falsy, so the `||` falls through 
to `Number.MIN_SAFE_INTEGER` and every value passes the guard, including `0`.
   
   This skips the label when the value is exactly `0`, before the threshold 
comparison.
   
   I used `numericValue !== 0` rather than the `numericValue > 0` suggested in 
the issue: `> 0` would also hide labels on negative segments, which do occupy 
space and legitimately need a label. There's a regression test covering that 
case.
   
   ### TESTING INSTRUCTIONS
   
   ```
   cd superset-frontend
   npm run test -- 
plugins/plugin-chart-echarts/test/Timeseries/transformers.test.ts
   ```
   
   Four tests were added under `transformSeries › stacked value labels`:
   
   - hides the label for a zero value when the threshold is `0` (fails without 
this change)
   - still shows the label for a non-zero value at threshold `0`
   - still shows the label for a negative value (guards against the `> 0` 
regression)
   - still hides a value that is below an explicit non-zero threshold
   
   Manually: create a Stacked Timeseries Bar chart with two metrics where one 
returns `0` for some x-values, turn on **Show Value**, and confirm the `0` 
labels no longer overlap the adjacent labels.
   
   ### ADDITIONAL INFORMATION
   - [x] Has associated issue: #42702
   - [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]

Reply via email to