Skip to content

Conversation

@natsuokawai
Copy link

@natsuokawai natsuokawai commented Nov 26, 2025

Brief Information

This pull request is in the type of:

  • 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

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.
events-on-matrix-cell-text.mov

Document Info

One of the following should be checked.

  • 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

@echarts-bot
Copy link

echarts-bot bot commented Nov 26, 2025

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.

Copy link
Contributor

@Ovilia Ovilia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Matrix is a layout so its text in the header or body should not trigger 'click' event by default. If you need this information, you need to add a new option matrix.triggerEvent (default false) like https://echarts.apache.org/en/option.html#yAxis.triggerEvent.

@natsuokawai
Copy link
Author

@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 natsuokawai requested a review from Ovilia November 30, 2025 05:14
Copy link
Contributor

@Ovilia Ovilia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add test cases in test/matrix.html.

name: textValue != null ? textValue + '' : null,
coord: xyLocator.slice()
};
getECData(cellRect).eventData = eventData;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that events only trigger when there is text, correct me if I'm wrong. So what's the meaning of setting eventData of cellRect here?

Copy link
Author

@natsuokawai natsuokawai Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ovilia
Sorry, you're right. I've removed the eventData from cellRect. Fixed in 1a12a50

@natsuokawai natsuokawai requested a review from Ovilia December 7, 2025 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants