waterWang opened a new pull request, #21737:
URL: https://github.com/apache/echarts/pull/21737

   Fixes #21732
   
   ## Problem
   
   `TooltipView._showAxisTooltip` iterates `axisItem.seriesDataIndices` whose 
`seriesIndex` values come from the cached pointer state 
(`_lastDataByCoordSys`). When a merged `setOption` removes series (e.g. 
`replaceMerge: ['series', ...]`) while the tooltip is still showing, those 
cached indices become stale and `ecModel.getSeriesByIndex(idxItem.seriesIndex)` 
returns `undefined`, causing:
   
   ```text
   Uncaught TypeError: Cannot read properties of undefined (reading 
'getDataParams')
       at TooltipView._showAxisTooltip
   ```
   
   ## Root cause
   
   1. `TooltipView` caches the last hovered pointer state in `_lastX` / 
`_lastY` / `_lastDataByCoordSys`.
   2. Every `setOption` runs `TooltipView.render()` → `_keepShow()`, which 
re-shows the tooltip with the cached `dataByCoordSys` after the update.
   3. The new option has fewer series than the cached indices refer to → 
`getSeriesByIndex` returns `undefined` → `series.getDataParams(...)` throws.
   
   ## Fix
   
   Two defensive guards in `_showAxisTooltip`:
   
   1. Skip stale `seriesDataIndices` entries whose series no longer exists: `if 
(!series) { return; }`
   2. Move the existing `!axisModel` guard **before** the `axisModel.axis` 
access (it was previously checked after being dereferenced), so a removed axis 
also short-circuits instead of crashing.
   
   ## Test
   
   With `tooltip: {trigger: 'axis'}`, hover to show the tooltip, then 
`setOption` with fewer series in merge mode — the tooltip no longer throws and 
safely skips removed series.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to