Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/component/tooltip/tooltipMarkup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions src/util/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1540,11 +1540,11 @@ export interface CommonTooltipOption<FormatterParams> {
formatter?: string | TooltipFormatterCallback<FormatterParams>

/**
* 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',
Expand Down
Loading