ant-design / ant-design-charts

A React Chart Library
https://ant-design-charts.antgroup.com/
MIT License
1.91k stars 361 forks source link

🐛[BUG] 2.x中双轴图 `legend: true` 和自定义 `tooltip` 不能同时设置 #2459

Open 2013xile opened 6 months ago

2013xile commented 6 months ago

🐛 bug 描述 [详细地描述 bug,让大家都能理解]

在新版双轴图中设置 legend: true 同时,自定义 tooltip,无法正常工作。

📷 复现步骤 [清晰描述复现步骤,让别人也能看到问题]

image

设置 legend: true, tooltipname 不生效

image

不设置 legend, tooltip 可以正常工作

🏞 期望结果 [描述你原本期望看到的结果]

设置 legend: true 不影响 tooltip 配置。

💻 复现代码 [提供可复现的代码,仓库,或线上示例]

https://ant-design-charts-next.antgroup.com/zh/examples/statistics/dual-axes/#dual-line

© 版本信息

2.1.4

🚑 其他信息 [如截图等其他信息可以贴在这里]

2013xile commented 6 months ago

看了下源码,发现定义 colorField 为函数可以同时解决 legendtooltip 配置。

image

不知道这是不是合理的方式。

lxfu1 commented 6 months ago

tooltip 配置和children同一层级试一下

2013xile commented 6 months ago

tooltip 配置和children同一层级试一下

image

一样的 只有 value 生效,name 不生效。

这里的目的其实是为了达到 1.x 版本 meta.alias 的效果。

wxj123654 commented 5 months ago

遇到了同样的问题,只能先用colorField了