echarts icon indicating copy to clipboard operation
echarts copied to clipboard

[Bug] brushMode: 'multiple' is not working

Open YuqiaoS opened this issue 1 month ago • 8 comments

Version

6

Link to Minimal Reproduction

https://echarts.apache.org/examples/en/editor.html?c=scatter-simple&code=PYBwLglsB2AEC8sDeAoWsAeBBDEDOAXMgL4A0asAnjvkUmRQEYBOArngBZ0XpjDAAbRsAxEA2gHJmAUwDGYCaVgSA1tOkhFy2QOkBDZhIC65dOhbsOAWWAATaUQkBbVgMghdEig3R5pzCGlCWDEeZDDfSidhAQBlCAAvB1gAJgAGUzN0Wz0wPXEIszEARjSAOgzYAA4KgBYTQvQxGrSAdiUANjKATgBWBqyskoBmCqVWst6qgcGm7orepRqq4pnZkuKx6rLh4bXBktqtiY6O_aHi0drOspXzotKtrt37puKjyprus8z14pTJjcqilXiF5sVFrAJiCUIV7oUwJQQMkJHhZLkwP4vFkfGZULNEcjHGiMVjflk8FEYvEkkR0uTsrl8iFYbM3ptIdDQWJRmlhkojik9gyHgCUuNbsLGiEAWlxbAjrVWtzNmlIaMXiKmh9IUdvtyunyJSl6lqQv8nmUUj9pSVZUtbqbbRM0lUlL1biCzWIPXL3WUOtM4eTiBQjChiABuIA

Steps to Reproduce

  1. Click on 'box' selection on the toolbox.
  2. Draw 1 box.
  3. Draw another box. (The previous box is cleared)

Current Behavior

The brush selection is 'single' even setting the brushMode: 'multiple'

Expected Behavior

The brush selection should be 'multiple' like the behavior after the 'keep' toolbox feature.

Environment

- OS:Windows
- Browser: Edge
- Framework:Vue@3

Any additional comments?

No response

YuqiaoS avatar Nov 07 '25 08:11 YuqiaoS

3. Draw another box. (The previous box is cleared)

That's because you need to select "Keep selections" first. Other than that, brushMode: 'multiple' operates as intended - Demo.

However, there is a bug in inBrush.opacity, see Demo code. See also similar #11649.

helgasoft avatar Nov 07 '25 17:11 helgasoft

  1. Draw another box. (The previous box is cleared)

That's because you need to select "Keep selections" first. Other than that, brushMode: 'multiple' operates as intended - Demo.

However, there is a bug in inBrush.opacity, see Demo code. See also similar #11649.

Then the option doesn't do anything. You can always click keep selection.

I want it as default. Is there anyway to do this programmatically?

YuqiaoS avatar Nov 11 '25 18:11 YuqiaoS

I want it as default. Is there anyway to do this programmatically?

I think yes, if we know the name of the "Keep Selections" action (which is currently undocumented), it could be dispatched programmatically. Perhaps the name could be extracted from the source code by an expert...

helgasoft avatar Nov 11 '25 20:11 helgasoft

Sorry, the "Keep Selections" action is documented and called takeGlobalCursor. Here is how to use it - Demo. 📌 please close issue if problem solved.

helgasoft avatar Nov 17 '25 02:11 helgasoft

Sorry, the "Keep Selections" action is documented and called takeGlobalCursor. Here is how to use it - Demo. 📌 please close issue if problem solved.

Thanks for the solution. I tried this before without the setTimeout and it did not work. I'd consider it resolved if the following are optimized?

  1. The brushMode: multiple option should have the "keep selection" selected as default without the dispatch action. Otherwise the option should be considered defective or obsolete.
  2. What is the reason for the setTimeout on dispatchAction? Is it because it needs to wait for the canvas rendering to finish (at the start)?

YuqiaoS avatar Nov 18 '25 13:11 YuqiaoS

  1. That's an opinion option which could be proposed as a new Feature
  2. Yes

helgasoft avatar Nov 19 '25 19:11 helgasoft

  1. That's an ~opinion~ option which could be proposed as a new Feature
  2. Yes
  1. The brushmode option is listed in the docs. If setting it to multiple doesn't actually do it, then it makes the following doc is incorrect? (The point is that even setting it as single, you can still use the keep selection (actually i think that's what the keep selection does. set it to multiple)

brush. brushMode = 'single' string Default brush mode, whose value can be:

'single': for single selection; 'multiple': for multiple selection.

YuqiaoS avatar Nov 20 '25 02:11 YuqiaoS

ok, finally I understand - brushmode:'multiple' is expected to (and should) activate "Keep Selections", that makes sense.

helgasoft avatar Nov 20 '25 02:11 helgasoft