You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by "Ovilia (via GitHub)" <gi...@apache.org> on 2025/12/03 08:26:44 UTC

Re: [PR] fix(matrix): trigger click event on matrix cells [echarts]

Ovilia commented on code in PR #21390:
URL: https://github.com/apache/echarts/pull/21390#discussion_r2584087792


##########
src/component/matrix/MatrixView.ts:
##########
@@ -339,26 +345,41 @@ function createMatrixCell(
     }
 
     // Set silent
+    const triggerEvent = matrixModel.get('triggerEvent');
     if (cellText) {
         let labelSilent = _tmpCellLabelModel.get('silent');
-        // auto, tooltip of text cells need silient: false, but non-text cells
-        // do not need a special cursor in most cases.
+        // By default, silent: false is needed for triggerEvent or tooltip interaction.
         if (labelSilent == null) {
-            labelSilent = !tooltipOptionShow;
+            labelSilent = !(triggerEvent || tooltipOptionShow);
         }
         cellText.silent = labelSilent;
         cellText.ignoreHostSilent = true;
     }
     let rectSilent = _tmpCellModel.get('silent');
     if (rectSilent == null) {
-        rectSilent = (
-            // If no background color in cell, set `rect.silent: false` will cause that only
-            // the border response to mouse hovering, which is probably weird.
+        // If no background color in cell, set `rect.silent: false` will cause that only
+        // the border response to mouse hovering, which is probably weird.
+        rectSilent = !(triggerEvent || tooltipOptionShow) || (
             !cellRect.style || cellRect.style.fill === 'none' || !cellRect.style.fill
         );
     }
     cellRect.silent = rectSilent;
 
+    if (triggerEvent) {
+        const eventData = {
+            componentType: 'matrix' as const,
+            componentIndex: matrixModel.componentIndex,
+            matrixIndex: matrixModel.componentIndex,
+            targetType: targetType,
+            name: textValue != null ? textValue + '' : null,
+            coord: xyLocator.slice()
+        };
+        getECData(cellRect).eventData = eventData;

Review Comment:
   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?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org