You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] dataIndex in tooltip.valueFormatter is not absolute when zooming #21477
When using dataIndex to get the raw value from underlying data array, the value retrieved is wrong when I zoom onto a few points. It looks like dataIndex is only considering the points displayed on the chart , i.e. it's 0 for the first visible point with the zoom on but it prevents me from using it to retrieve the raw value from the underlying data array.
No zoom:
With zoom:
Expected Behavior
I expect the dataIndex to refer to the absolute index of the value within the underlying data array, no matter what the zoom context is.
// Do not mix display seriesName and itemName in one tooltip,
// which might confuses users.
name: inlineName,
// name dimension might be auto assigned, where the name might
// be not readable. So we check trim here.
noName: !trim(inlineName),
value: inlineValue,
valueType: inlineValueType,
dataIndex
return createTooltipMarkup('section', {
header: seriesName,
// When series name is not specified, do not show a header line with only '-'.
// This case always happens in tooltip.trigger: 'item'.
noHeader: multipleSeries || !seriesNameSpecified,
sortParam: sortParam,
blocks: [
createTooltipMarkup('nameValue', {
markerType: 'item',
markerColor: markerColor,
// Do not mix display seriesName and itemName in one tooltip,
// which might confuses users.
name: inlineName,
// name dimension might be auto assigned, where the name might
// be not readable. So we check trim here.
noName: !trim(inlineName),
value: inlineValue,
valueType: inlineValueType,
- dataIndex+ dataIndex,+ rawDataIndex: data.getRawIndex(dataIndex)
})
].concat(subBlocks || [] as any)
});
Activity
plainheart commentedon Jan 15, 2026
Thanks for your report! This is a case that is not covered by the original PR #19123.
Currently, the dataIndex is actually
dataIndexInside, which is the index within the visible data range.echarts/src/component/tooltip/TooltipView.ts
Line 579 in 0919819
plainheart commentedon Jan 15, 2026
A possible quick fix may be to add the raw absolute dataIndex
rawDataIndexand take it as the callback parameter ofvalueFormatter.echarts/src/component/tooltip/seriesFormatTooltip.ts
Lines 89 to 97 in 0919819
return createTooltipMarkup('section', { header: seriesName, // When series name is not specified, do not show a header line with only '-'. // This case always happens in tooltip.trigger: 'item'. noHeader: multipleSeries || !seriesNameSpecified, sortParam: sortParam, blocks: [ createTooltipMarkup('nameValue', { markerType: 'item', markerColor: markerColor, // Do not mix display seriesName and itemName in one tooltip, // which might confuses users. name: inlineName, // name dimension might be auto assigned, where the name might // be not readable. So we check trim here. noName: !trim(inlineName), value: inlineValue, valueType: inlineValueType, - dataIndex + dataIndex, + rawDataIndex: data.getRawIndex(dataIndex) }) ].concat(subBlocks || [] as any) });echarts/src/component/tooltip/tooltipMarkup.ts
Lines 349 to 351 in 0919819
bchazalet commentedon Jan 15, 2026
thanks for the quick response @plainheart! And for the link to the original PR.
Thanks for confirming. So are you saying this was meant to be the raw index and this is indeed a bug?
fix(tooltip): valueFormatter cb param dataIndex should be rawDataInde…
plainheart commentedon Jan 15, 2026
@bchazalet Yeah, you are right. This is a bug and will be fixed in #21479.