How to get the hovered element on Line Chart using Recharts

荒凉一梦 提交于 2020-01-16 18:55:05

问题


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

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.


回答1:


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>
  );
}


来源:https://stackoverflow.com/questions/49142917/how-to-get-the-hovered-element-on-line-chart-using-recharts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!