diff --git a/src/component/tooltip/tooltipMarkup.ts b/src/component/tooltip/tooltipMarkup.ts index b51fe55ca9..a5e66ed1ed 100644 --- a/src/component/tooltip/tooltipMarkup.ts +++ b/src/component/tooltip/tooltipMarkup.ts @@ -324,7 +324,7 @@ function buildNameValue( const noMarker = !fragment.markerType; const name = fragment.name; const useUTC = ctx.useUTC; - const valueFormatter = fragment.valueFormatter || ctx.valueFormatter || ((value) => { + const valueFormatter = fragment.valueFormatter || ctx.valueFormatter || ((value, dataIndex, name) => { // Added params here value = isArray(value) ? value : [value]; return map(value as unknown[], (val, idx) => makeValueReadable( val, isArray(valueTypeOption) ? valueTypeOption[idx] : valueTypeOption, useUTC @@ -347,8 +347,8 @@ function buildNameValue( : makeValueReadable(name, 'ordinal', useUTC); const valueTypeOption = fragment.valueType; const readableValueList = noValue - ? [] - : valueFormatter(fragment.value as OptionDataValue, fragment.dataIndex); + ? [] + : valueFormatter(fragment.value as OptionDataValue, fragment.dataIndex, fragment.name); // Added fragment.name const valueAlignRight = !noMarker || !noName; // It little weird if only value next to marker but far from marker. const valueCloseToMarker = !noMarker && noName; diff --git a/src/util/types.ts b/src/util/types.ts index 1d6521d51e..41bf178806 100644 --- a/src/util/types.ts +++ b/src/util/types.ts @@ -1540,11 +1540,11 @@ export interface CommonTooltipOption { formatter?: string | TooltipFormatterCallback /** - * Formatter of value. - * - * Will be ignored if tooltip.formatter is specified. - */ - valueFormatter?: (value: OptionDataValue | OptionDataValue[], dataIndex: number) => string + * Formatter of value. + * + * Will be ignored if tooltip.formatter is specified. + */ +valueFormatter?: (value: OptionDataValue | OptionDataValue[], dataIndex: number, name?: string) => string | string[] /** * Absolution pixel [x, y] array. Or relative percent string [x, y] array. * If trigger is 'item'. position can be set to 'inside' / 'top' / 'left' / 'right' / 'bottom',