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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion __tests__/integration/api-chart-emit-tooltip-show.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('chart.emit tooltip with line', () => {
container.querySelector('.tooltip-content');

expect(tooltipData?.innerText).toEqual(
`{"title":"1997","items":[{"value":7,"color":"#1783FF","name":"value"}],"data":{"x":"1997"}}`,
`{"title":"1997","items":[{"value":7,"color":"#1783FF","name":"value","channel":"value"}],"data":{"x":"1997"}}`,
);
});

Expand Down
1 change: 1 addition & 0 deletions src/interaction/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ function groupItems(
...item,
color,
name: name1 || title,
channel: name,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

新属性 channel 的命名可以更具描述性。根据 PR 的描述,这个属性旨在保留 y 轴编码中的原始字段名,当使用 series 时,该字段名会丢失。

在 G2 中,channel 一词通常指代像 xycolor 这样的视觉通道。这里存储的值是映射到某个通道的数据集中的字段field)。因此,将此属性命名为 field 会更准确,对于自定义 tooltip 的用户来说也不会那么模棱两可。

我建议将 channel 重命名为 field。这将使该属性在 tooltip item 数据结构中的用途更加清晰。

Suggested change
channel: name,
field: name,
Copy link
Member

@lxfu1 lxfu1 Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感觉可以参考 code assist ,field 挺好的。

};
},
);
Expand Down
Loading