From ebe277cd65ccb88dc5e9775e2c2fb23cc246f33a Mon Sep 17 00:00:00 2001 From: water <672684719@qq.com> Date: Sun, 16 Aug 2026 16:24:48 +0800 Subject: [PATCH] fix(tooltip): guard against removed series in cached axis tooltip params Fixes #21732 _showAxisTooltip iterates `axisItem.seriesDataIndices` whose seriesIndex values come from the cached `_lastDataByCoordSys` pointer state. When a merged setOption removes series (e.g. `replaceMerge: ['series']`), those indices become stale and `getSeriesByIndex` returns undefined, causing: Uncaught TypeError: Cannot read properties of undefined (reading getDataParams) Also moved the `!axisModel` guard before the `axisModel.axis` access so a removed axis handles the same way instead of crashing earlier. --- src/component/tooltip/TooltipView.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/component/tooltip/TooltipView.ts b/src/component/tooltip/TooltipView.ts index 044a12ffca..b10ff63552 100644 --- a/src/component/tooltip/TooltipView.ts +++ b/src/component/tooltip/TooltipView.ts @@ -555,11 +555,11 @@ class TooltipView extends ComponentView { each(itemCoordSys.dataByAxis, function (axisItem) { const axisModel = ecModel.getComponent(axisItem.axisDim + 'Axis', axisItem.axisIndex) as AxisBaseModel; const axisValue = axisItem.value; - const axis = axisModel.axis; - const axisValueParsed = axis.scale.parse(axisValue); if (!axisModel || axisValue == null) { return; } + const axis = axisModel.axis; + const axisValueParsed = axis.scale.parse(axisValue); // FIXME: when using `tooltip.trigger: 'axis'`, the precision of the axis value displayed in tooltip // should match the original series values rather than using the default strategy in Interval.ts // (getPrecision(interval) + 2); otherwise it may cause confusion. @@ -578,6 +578,9 @@ class TooltipView extends ComponentView { each(axisItem.seriesDataIndices, function (idxItem) { const series = ecModel.getSeriesByIndex(idxItem.seriesIndex); + if (!series) { + return; + } const dataIndex = idxItem.dataIndexInside; const cbParams = series.getDataParams(dataIndex) as TooltipCallbackDataParams; // Can't find data.