Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the hovered element on Line Chart using Recharts

I am actually new here. And new in ReactJS too :(

enter image description here

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. So as you can see that's not the case with this tooltip.

Please help I really need it.

like image 545
Danielle Mae Calugcugan Tugare Avatar asked Dec 11 '25 18:12

Danielle Mae Calugcugan Tugare


1 Answers

Try this code on each Line element

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>
  );
}
like image 112
Iniamudhan Avatar answered Dec 15 '25 17:12

Iniamudhan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!