This is an automated email from the ASF dual-hosted git repository. sushuang pushed a commit to branch fix-tooltip-valueformatter in repository https://gitbox.apache.org/repos/asf/echarts.git
commit 56c87685b3ae4c07150a5d0eb7898983a6c349be Author: 100pah <[email protected]> AuthorDate: Thu Jan 15 23:46:31 2026 +0800 fix(tooltip): valueFormatter cb param dataIndex should be rawDataIndex rather than dataZoom filtered dataIndex. Close #21477 . --- src/component/tooltip/seriesFormatTooltip.ts | 2 +- src/component/tooltip/tooltipMarkup.ts | 4 ++-- test/tooltip-valueFormatter.html | 9 ++++++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/component/tooltip/seriesFormatTooltip.ts b/src/component/tooltip/seriesFormatTooltip.ts index 714cac2df..88182fde0 100644 --- a/src/component/tooltip/seriesFormatTooltip.ts +++ b/src/component/tooltip/seriesFormatTooltip.ts @@ -94,7 +94,7 @@ export function defaultSeriesFormatTooltip(opt: { noName: !trim(inlineName), value: inlineValue, valueType: inlineValueType, - dataIndex + rawDataIndex: data.getRawIndex(dataIndex), }) ].concat(subBlocks || [] as any) }); diff --git a/src/component/tooltip/tooltipMarkup.ts b/src/component/tooltip/tooltipMarkup.ts index b51fe55ca..2524f753d 100644 --- a/src/component/tooltip/tooltipMarkup.ts +++ b/src/component/tooltip/tooltipMarkup.ts @@ -174,7 +174,7 @@ export interface TooltipMarkupNameValueBlock extends TooltipMarkupBlock { // null/undefined/NaN/''... (displayed as '-'). noName?: boolean; noValue?: boolean; - dataIndex?: number; + rawDataIndex?: number; valueFormatter?: CommonTooltipOption<unknown>['valueFormatter'] } @@ -348,7 +348,7 @@ function buildNameValue( const valueTypeOption = fragment.valueType; const readableValueList = noValue ? [] - : valueFormatter(fragment.value as OptionDataValue, fragment.dataIndex); + : valueFormatter(fragment.value as OptionDataValue, fragment.rawDataIndex); const valueAlignRight = !noMarker || !noName; // It little weird if only value next to marker but far from marker. const valueCloseToMarker = !noMarker && noName; diff --git a/test/tooltip-valueFormatter.html b/test/tooltip-valueFormatter.html index 3d48e8e97..4690eb275 100644 --- a/test/tooltip-valueFormatter.html +++ b/test/tooltip-valueFormatter.html @@ -284,6 +284,11 @@ under the License. yAxis: { type: 'value' }, + dataZoom: [{ + type: 'slider', + }, { + type: 'inside', + }], series: [ { type: 'bar', @@ -293,7 +298,9 @@ under the License. }; var chart = testHelper.create(echarts, 'main3', { - title: ['dataIndex in valueFormatter'], + title: [ + 'dataIndex in valueFormatter should be consistent when dataZoom is used' + ], option: option }); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
