echarts icon indicating copy to clipboard operation
echarts copied to clipboard

fix(matrix): trigger click event on matrix cells

Open natsuokawai opened this issue 3 months ago • 2 comments

Brief Information

This pull request is in the type of:

  • [x] bug fixing
  • [ ] new feature
  • [ ] others

What does this PR do?

Fixes an issue where click events were not triggered on matrix component cells.

Fixed issues

  • #21389

Details

Before: What was the problem?

Even when matrix.body.silent was set to false (and the cell was made hit-testable, e.g., by setting itemStyle.color to 'transparent'), click events on matrix cells were not being emitted by the ECharts instance. This was because the underlying graphic elements (rects and texts) created in MatrixView lacked the necessary eventData (ECData) to identify them as part of the matrix component.

After: How does it behave after the fixing?

Click events are now correctly triggered when clicking on matrix cells. The event parameters include componentType: 'matrix', componentIndex, and the cell's name.

This is achieved by:

  1. Importing getECData in src/component/matrix/MatrixView.ts.
  2. Attaching eventData to the cell's text elements during creation in createMatrixCell.

https://github.com/user-attachments/assets/14b3c87c-d7c0-48ec-85f6-1d30858120ac

Document Info

One of the following should be checked.

  • [x] This PR doesn't relate to document changes
  • [ ] The document should be updated later
  • [ ] The document changes have been made in apache/echarts-doc#xxx

Misc

Security Checking

  • [ ] This PR uses security-sensitive Web APIs.

ZRender Changes

  • [ ] This PR depends on ZRender changes (ecomfe/zrender#xxx).

Related test cases or examples to use the new APIs

Added a new test case in test/ut/spec/component/matrix/event.test.ts to verify the fix.

Merging options

  • [ ] Please squash the commits into a single one when merging.

Other information

natsuokawai avatar Nov 26 '25 08:11 natsuokawai

Thanks for your contribution! The community will review it ASAP. In the meanwhile, please checkout the coding standard and Wiki about How to make a pull request.

Please DO NOT commit the files in dist, i18n, and ssr/client/dist folders in a non-release pull request. These folders are for release use only.

echarts-bot[bot] avatar Nov 26 '25 08:11 echarts-bot[bot]

@Ovilia Thank you for your review and the helpful feedback!

I've updated the implementation to add the triggerEvent option (default: false) following the same pattern as yAxis.triggerEvent.

I would appreciate it if you could take another look.

natsuokawai avatar Nov 30 '25 05:11 natsuokawai

@Ovilia Just checking in on this. Let me know if you need any more time or if there's anything else I can do.

natsuokawai avatar Dec 22 '25 01:12 natsuokawai