I have .NET Framework 4.8 WinForms application and a chart with 4 stacking 3D bars.
I use the following code to show a tooltip then cursor is above any bar point:
Code: Select all
private void tChart1_MouseMove(object sender, MouseEventArgs e)
{
Int32 clickedPointIndex = -1, clickedSeriesIndex = -1;
var chart = sender as TChart;
//search for cursor hitting point of any bar
for (int i = 0; i < chart.Series.Count; i++)
{
if ((chart.Series[i] is CustomBar) && ((chart.Series[i] as CustomBar).Clicked(e.X, e.Y) != -1))
{
clickedSeriesIndex = i;
clickedPointIndex = (chart.Series[i] as CustomBar).Clicked(e.X, e.Y);
break;
}
}
if (clickedPointIndex != -1)
{
//when cursor was moved from one point to another on the same bar - tooltip must be changed
if ((clickedSeriesIndex != prevClickedSeriesIndex) || (clickedPointIndex != prevClickedPointIndex))
{
toolTip1.Active = false;
toolTip1.SetToolTip(sender as TChart, $"{chart.Series[clickedSeriesIndex].Title} - {chart.Series[clickedSeriesIndex][clickedPointIndex].Y}");
toolTip1.Active = true;
prevClickedSeriesIndex = clickedSeriesIndex;
prevClickedPointIndex = clickedPointIndex;
}
else
if (!toolTip1.Active)
{
toolTip1.SetToolTip(chart, $"{chart.Series[clickedSeriesIndex].Title} - {chart.Series[clickedSeriesIndex][clickedPointIndex].Y}");
toolTip1.Active = true;
}
}
else
toolTip1.Active = false;
}
My test project
Fix that please ASAP, this bug completely stops my work for now.