[Bug] Toggling `label.show` does not behave correctly when hovering over a bar in the barChart
Version
5.5.1
Link to Minimal Reproduction
https://codepen.io/robin-gerling/pen/abgYVLZ
Steps to Reproduce
- Initialization: Simple
optioncontaining only data for the bar chart andlabel.show = truefor the series - Update the option with
chart.setOption(option);(by clicking on "Toggle bar values" in the minimal reproduction) - Hover over the bars
Current Behavior
The label for a bar appears when hovering over the bar even though label.show is false.
In case the initial value for label.show is true and the option is changed to true, the label for a bar will hide when hovering over the bar.
Expected Behavior
When label.show = false the labels should be not shown at any time (and not appear on hover).
When label.show = true the labels should be shown at any time (and not disappear on hover).
Environment
- OS:
- Browser:
- Framework:
Any additional comments?
Could be related to https://github.com/apache/echarts/issues/17554.
However, https://github.com/apache/echarts/issues/17554, additionally sets labelLayout.hideOverlap.
The minimal reproduction contains two buttons. Pressing "Clear chart & Toggle bar values" additionally clears the chart (chart.clear();). Clearing helps resolving this bug.
The label for a bar appears when hovering over the bar even though label.show is false.
this effect comes from emphasis.label.show Labels and emphasis switch fine - Demo 📌 please close issue if problem solved.
Thank you for the quick answer. This solves the problem. But, I would argue that this is a workaround, as is clearing the chart, because when the chart is initialized, emphasis.label.show takes the value of label.show. I would therefore expect the same when changing label.show and keep the issue open (except it is confirmed that setting emphasis.label.show is expected wanted behaviour).
However, setting emphasis.label.show is a much better workaround than having to clear the chart.
The label for a bar appears when hovering over the bar even though label.show is false.
this effect comes from emphasis.label.show Labels and emphasis switch fine - Demo 📌 please close issue if problem solved.
This workared doesn't work when some data label are not visible due to the overlap.
After changing both show to false, the invisible data labels still get shown when hovering.
Demo
I found a new workaround : Demo
You just update the formatter.
It looks like the new formatter will refresh the unexpected data label cache