gkhnelbstn opened a new issue, #42702:
URL: https://github.com/apache/superset/issues/42702
## 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 (since a zero-height stacked segment starts and ends at the same
y-coordinate as the top of the previous segment). This produces a garbled,
overlapping text (e.g. two labels rendered on top of each other) wherever any
series is `0` for a category.
Related to, but distinct from, #42701 (which is about the "Only Total" sum
being wrong) — this one is about per-series labels overlapping in the default
(non-"Only Total") stacked label mode.
## Reproduction
1. Create an `echarts_timeseries_bar` chart with 2 metrics (e.g. `A`, `B`),
Stacked, "Show Value" on, "Only Total" off, "Percentage threshold" left at its
default (`0`).
2. Include at least one x-axis category where one metric is `0` and the
other is a large number, e.g. `{"category": "1-3g", "A": 32, "B": 0}`.
3. Run the chart.
4. **Bug**: the label for `B` (`0`) renders directly on top of the label for
`A` (`32`), since `B`'s stacked segment has zero height and starts exactly
where `A`'s segment ends. The two labels visually overlap into unreadable,
doubled text.
5. For categories where both metrics are non-zero, the labels render at
distinct heights and don't collide — confirming this is specific to the
zero-value case.
## Root cause
`plugins/plugin-chart-echarts/src/Timeseries/transformers.ts`, the
per-series `label.formatter`:
```ts
if (!onlyTotal) {
if (
numericValue >=
(thresholdValues[dataIndex] || Number.MIN_SAFE_INTEGER)
) {
return formatter(numericValue);
}
return '';
}
```
`thresholdValues[dataIndex]` comes from `extractDataTotalValues` in
`plugins/plugin-chart-echarts/src/utils/series.ts`:
```ts
thresholdValues.push(((percentageThreshold || 0) / 100) * values);
```
With the default `percentage_threshold: 0` (very common — it's the field's
default), `thresholdValues[dataIndex]` is `0` for every row, so the condition
becomes `numericValue >= 0`, which a value of exactly `0` always satisfies. The
label is shown for a segment with literally no visible height, landing exactly
on top of the neighboring segment's own label.
## Suggested fix
Require the value to be strictly positive (or otherwise non-zero) before
showing a per-series stacked label, regardless of the configured threshold:
```ts
if (!onlyTotal) {
if (
numericValue > 0 &&
numericValue >=
(thresholdValues[dataIndex] || Number.MIN_SAFE_INTEGER)
) {
return formatter(numericValue);
}
return '';
}
```
(A zero-height stacked segment has no meaningful position to attach a label
to regardless of threshold settings, so this seems safe as a default rather
than something that should require the user to configure a percentage
threshold.)
## Workaround
Set **Percentage threshold** to a small positive value (e.g. `1`). This
makes `thresholdValues[dataIndex]` a positive number for any category with a
non-zero total, so a `0`-valued series no longer clears the threshold and its
label is suppressed — eliminating the overlap without needing to touch every
category's data. Only works if you don't also want threshold-based hiding of
small-but-nonzero values, which is an inherent tradeoff of using this control
as the workaround.
## Environment
- Superset version: 6.1.0 (confirmed present at `refs/tags/6.1.0`)
- Chart type: `echarts_timeseries_bar` (Time-series Bar Chart), stacked,
"Show Value" on, "Only Total" off
--
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]