Version
6.1.0
Link to Minimal Reproduction
https://echarts.apache.org/examples/en/editor.html?code=PYBwLglsB2AEC8sDeAoWszGAGwEbAA8AuZNdWCMAUwFsBlCALypICYAGAGjPQHpfYAOWAAnGgENsFAMYwAziQAm4kQGtYAcxHiAngDpYACQgaAFthOnqimfJKjx0DVT09b0OmB3YWyWPhFFKhEAYRxREgByAGIAZnjI2ABfbnJYWhBTcTkIBT8IWQ8vHxIkf1Eg0PCRKIcnKkSk5NTyADMqcTAAVxFfVDT0CQ0CgBUdED6Mcd8AbUiLaAbOWEjcFUiAXWa3dFwRLrlTUqS3E_QUsj2Do78CAEECXIBJaCDiWHZt9HvHvP7yLwTKLSTpUDSiHSRFroZRgcQkOYAWRgUJWIy6SxWAHUqIpUZERqYuviAGIiCD4uidSldaCbMgXdA6B65Y4tOTBCBUPIzNz_NKA3yrdbQ8iw-GwGYARg4yw4XFgUoArAqABwKgDsCqlUu1sXYG1OZENSQA3CggA
Steps to Reproduce
- Open the link above.
- Click the toolbox icon "Box Select".
- Drag in the chart to brush an area.
- Click the toolbox icon "Switch to Line Chart". Anything else that triggers a full update works too.
- Click the toolbox icon "Clear Selections", and then move the mouse out of the icon.
Current Behavior
The highlight of the icon "Clear Selections" does not follow the brushed areas:
| Step |
Brushed areas |
"Clear Selections" |
| After step 3 |
1 |
Not highlighted |
| After step 4 |
1 |
Highlighted |
| After step 5 |
0 |
Still highlighted |
It only goes back to normal after the next full update, for example, after clicking "Switch to Bar Chart".
Expected Behavior
The icon should be highlighted as soon as an area is brushed, and should go back to normal as soon as the areas are cleared.
Environment
- OS: macOS
- Browser: Chrome 153
- Framework: none
Any additional comments?
It can also be reproduced on the current master.
Cause
- The status of the brush icons is only calculated in
render and updateView of the toolbox brush feature (src/component/toolbox/feature/Brush.ts).
- The action
brush is registered with update: 'updateVisual' (src/component/brush/install.ts), and it is the only action that uses it. ToolboxView does not implement updateVisual, so the icons are not updated when the brushed areas are changed.
- Clicking "Clear Selections" dispatches
axisAreaSelect first, which triggers a full update while the areas still exist, and then brush with command: 'clear', which only updates visual. That is why the icon stays highlighted.
Relation to #21684
#21684 fixes that updateView and dispose of ToolboxView do nothing, because the HashMap of features is iterated by zrUtil.each. That fix is needed here, but it does not resolve this issue by itself. I applied it to master and the steps above give the same result.
Possible fix
On top of #21684:
- Implement
updateVisual in ToolboxView and delegate it to updateView.
- Apply the icon status by
api.enterEmphasis / api.leaveEmphasis instead of the ones in util/states, so that the states are applied in the next frame even if the status is changed out of a full update.
I have verified this locally and would like to make a pull request for it.
Version
6.1.0
Link to Minimal Reproduction
https://echarts.apache.org/examples/en/editor.html?code=PYBwLglsB2AEC8sDeAoWszGAGwEbAA8AuZNdWCMAUwFsBlCALypICYAGAGjPQHpfYAOWAAnGgENsFAMYwAziQAm4kQGtYAcxHiAngDpYACQgaAFthOnqimfJKjx0DVT09b0OmB3YWyWPhFFKhEAYRxREgByAGIAZnjI2ABfbnJYWhBTcTkIBT8IWQ8vHxIkf1Eg0PCRKIcnKkSk5NTyADMqcTAAVxFfVDT0CQ0CgBUdED6Mcd8AbUiLaAbOWEjcFUiAXWa3dFwRLrlTUqS3E_QUsj2Do78CAEECXIBJaCDiWHZt9HvHvP7yLwTKLSTpUDSiHSRFroZRgcQkOYAWRgUJWIy6SxWAHUqIpUZERqYuviAGIiCD4uidSldaCbMgXdA6B65Y4tOTBCBUPIzNz_NKA3yrdbQ8iw-GwGYARg4yw4XFgUoArAqABwKgDsCqlUu1sXYG1OZENSQA3CggA
Steps to Reproduce
Current Behavior
The highlight of the icon "Clear Selections" does not follow the brushed areas:
It only goes back to normal after the next full update, for example, after clicking "Switch to Bar Chart".
Expected Behavior
The icon should be highlighted as soon as an area is brushed, and should go back to normal as soon as the areas are cleared.
Environment
Any additional comments?
It can also be reproduced on the current
master.Cause
renderandupdateViewof the toolbox brush feature (src/component/toolbox/feature/Brush.ts).brushis registered withupdate: 'updateVisual'(src/component/brush/install.ts), and it is the only action that uses it.ToolboxViewdoes not implementupdateVisual, so the icons are not updated when the brushed areas are changed.axisAreaSelectfirst, which triggers a full update while the areas still exist, and thenbrushwithcommand: 'clear', which only updates visual. That is why the icon stays highlighted.Relation to #21684
#21684 fixes that
updateViewanddisposeofToolboxViewdo nothing, because theHashMapof features is iterated byzrUtil.each. That fix is needed here, but it does not resolve this issue by itself. I applied it tomasterand the steps above give the same result.Possible fix
On top of #21684:
updateVisualinToolboxViewand delegate it toupdateView.api.enterEmphasis/api.leaveEmphasisinstead of the ones inutil/states, so that the states are applied in the next frame even if the status is changed out of a full update.I have verified this locally and would like to make a pull request for it.