How can I make the tooltip follow the cursor in a pie chart made using recharts?
Currently, a tooltip is shown but it is just stuck at a location until the cursor directly moves into it. what I need is a tooltip which moves along with the cursor. I can be at a specific position may be at the top of the chart or anything.
Demo: https://jsfiddle.net/kg7Ldj1o/
I need something like this shown in the radial bar chart.http://recharts.org/en-US/api/RadialBarChart Here the tooltip moves along with the cursor.
<PieChart width={800} height={400} onMouseEnter={this.onPieEnter}>
<Tooltip />
<Pie
data={data}
cx={420}
cy={200}
startAngle={180}
endAngle={0}
cornerRadius={40}
innerRadius={60}
outerRadius={80}
fill="#8884d8"
paddingAngle={-15}
>
{data.map((entry, index) => (
<Cell
fill={
index === 0 || index === data.length - 1
? COLORS[index % COLORS.length]
: 'transparent'
}
stroke={
index === 0 || index === data.length - 1
? COLORS[index % COLORS.length]
: 'transparent'
}
/>
))}
</Pie>
<Pie
data={data}
cx={420}
cy={200}
startAngle={180}
endAngle={0}
cornerRadius={0}
innerRadius={60}
outerRadius={80}
fill="#8884d8"
>
{data.map((entry, index) => (
<Cell
fill={
index === 0 || index === data.length - 1
? 'transparent'
: COLORS[index % COLORS.length]
}
stroke={
index === 0 || index === data.length - 1
? 'transparent'
: COLORS[index % COLORS.length]
}
/>
))}
</Pie>
</PieChart>;