简体   繁体   English

如何使用 Recharts 获取折线图上的悬停元素

[英]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>
  );
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM