[英]How to get the hovered element on Line Chart using Recharts
I am actually new here.我实际上是新来的。 And new in ReactJS too :(
ReactJS 也是新的 :(
What I'm trying to do is when I hover over the value 1 line, only the value 1 data will be shown inside the tooltip.我想要做的是,当我将鼠标悬停在值 1 行上时,工具提示内只会显示值 1 数据。 So as you can see that's not the case with this tooltip.
如您所见,此工具提示并非如此。
Please help I really need it.请帮助我真的需要它。
Try this code on each Line element在每个 Line 元素上尝试此代码
activeDot={{onMouseOver:this.customMouseOver}}
Create a method to handle it创建一个方法来处理它
customMouseOver(e){
return (
<div className="customMouseOver">
//e hold the line data in payload element
</div>
);
}
Recharts Line activeDot function with custom tooltip带有自定义工具提示的 Recharts Line activeDot 函数
https://codesandbox.io/embed/recharts-issue-activedot-forked-k8norr?fontsize=14&hidenavigation=1&theme=dark https://codesandbox.io/embed/recharts-issue-activedot-forked-k8norr?fontsize=14&hidenavigation=1&theme=dark
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.