Skip to content

Commit ec4d8fc

Browse files
authored
fix(charts): tooltip must call value formatter (#11711)
1 parent 3a5246e commit ec4d8fc

File tree

1 file changed

+7
-5
lines changed
  • packages/react-charts/src/echarts/components/utils

1 file changed

+7
-5
lines changed

packages/react-charts/src/echarts/components/utils/tooltip.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,10 @@ export const getSankeyTooltip = (series: any[], option: ChartsOptionProps) => {
7171
const defaults = {
7272
confine: true,
7373
formatter: (params: any) => {
74-
const result = `
75-
<div style="display: inline-block; background-color: ${params.color}; height: ${symbolSize}; width: ${symbolSize};"></div>
76-
${params.name} ${params.value}
77-
`;
74+
let result;
7875
if (params?.data?.source && params?.data?.target) {
7976
const { sourceColor, targetColor } = getItemColor(series, params);
80-
return `
77+
result = `
8178
<p>${sourceLabel}</p>
8279
<div style="display: inline-block; background-color: ${sourceColor}; height: ${symbolSize}; width: ${symbolSize};"></div>
8380
${params.data.source}
@@ -90,6 +87,11 @@ export const getSankeyTooltip = (series: any[], option: ChartsOptionProps) => {
9087
</strong>
9188
</p>
9289
`;
90+
} else {
91+
result = `
92+
<div style="display: inline-block; background-color: ${params.color}; height: ${symbolSize}; width: ${symbolSize};"></div>
93+
${params.name} ${valueFormatter(params.value, params.dataIndex)}
94+
`;
9395
}
9496
return result.replace(/\s\s+/g, ' ');
9597
},

0 commit comments

Comments
 (0)