sfirke opened a new issue, #45470:
URL: https://github.com/apache/superset/issues/45470
### Bug description
(I used Claude AI to assist in writing up an error I encountered - I have
read and edited this)
In 7.0.0rc2, a Bar Chart with "Show value" on hides the value label of any
bar shorter than 16px along the value axis. This happens even when the chart
isn't stacked and the label sits outside the bar, where there is plenty of room
to draw it. In 6.1.0 these labels show.
Our case is a horizontal bar chart of counts. Values range from 1 to ~2,300,
so the axis runs 0–2,500 across about 1,440px. The bar for value `1` is under
1px wide and gets no label. The `74` bar is about 42px wide and keeps its
label. A companion chart of the same units as percentages shows `0.0%` on that
bar in 6.1.0. In 7.0.0rc2 it shows no label.
The cause is the label legibility floor in
`superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts`:
```ts
const MIN_LABEL_SEGMENT_SIZE_PX = 16;
function isBelowLabelLegibilityFloor(params, isHorizontal) {
const segmentSize = isHorizontal
? Math.abs(params.rect.width)
: Math.abs(params.rect.height);
return segmentSize < MIN_LABEL_SEGMENT_SIZE_PX;
}
```
- #43144 added this floor to the **Auto** label position.
- #44469 applied it to the **manual** positions as well (via
`createBarLabelLegibilityFloorLayout`).
The floor applies to every bar series, so switching the "Value label
position" setting doesn't bring the label back.
The code comment gives the reason for the floor: on a thin **stacked**
segment, both an inside and an outside label collide with a neighboring
segment's label (#44466). That reasoning doesn't hold for a non-stacked bar.
Its outside label has nothing next to it. Nothing in
`isBelowLabelLegibilityFloor` or its callers checks `stack`, so the floor
applies to non-stacked charts too.
The same code is on `master` today.
**How to reproduce**
1. Create a Bar Chart (horizontal or vertical) with a categorical dimension,
one metric, no stacking, and "Show value" on.
2. Use data where one value is very small compared with the largest, e.g.
`[2300, 1500, 400, 75, 1]`, or one value is `0`.
3. The bar for `1` (or `0`) has no value label. Try each "Bar label
position" option; the label is missing in all of them.
**Expected behavior**
As in 6.1.0, every bar in a non-stacked chart shows its value label. A label
that doesn't fit inside the bar is drawn just past its end, which Auto already
does for bars above the floor.
**Proposed fix**
Apply the floor only to stacked series, where the collision it prevents can
happen:
- Auto position: for a non-stacked series, skip the floor.
`getAutoBarLabelLayout` then finds that the label doesn't fit inside the bar
and moves it outside.
- Manual positions: attach `createBarLabelLegibilityFloorLayout` only when
the series is stacked.
Unit tests should cover a non-stacked horizontal and vertical bar of value
`1` and `0` next to a large value, for Auto and Outside end.
### Screenshots/recordings
<img width="1691" height="782" alt="Image"
src="https://github.com/user-attachments/assets/f7548a67-599c-4e68-a396-185c4fa10d5f"
/>
In 6.1.0 running in production, the label for bar L1-1 is "1"
### Superset version
master / latest-dev
### Python version
Not applicable
### Node version
Not applicable
### Browser
Not applicable
### Additional context
Superset 7.0.0rc2
### Checklist
- [x] I have searched Superset docs and Slack and didn't find a solution to
my problem.
- [x] I have searched the GitHub issue tracker and didn't find a similar bug
report.
- [x] I have checked Superset's logs for errors and if I found a relevant
Python stacktrace, I included it here as text in the "additional context"
section.
--
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]