I have an MsChart control with several SeriesChartType.Polar series. On chart's MouseMove event I check if it's over a DataPoint and if yes, I generate a ToolTip containing coordinates of the DataPoint under the mouse cursor.
It works well for angles (it's a polar chart) from 0 to 347 deg. The rest of the DataPoints is hidden under the ChartElementType.Axis and/or ChartElementType.AxisLabel, so I cannot get the DataPoint.PointIndex.
private void chart0_MouseMove(object sender, MouseEventArgs e)
{
var pos = e.Location;
HitTestResult result = chart0.HitTest(e.X, e.Y);
if (result.ChartElementType == ChartElementType.DataPoint )
{
var selectedValueY = chart0.Series[result.Series.Name].Points[result.PointIndex].YValues[0];
var selectedValueX = chart0.Series[result.Series.Name].Points[result.PointIndex].XValue;
selectedValueY = Math.Round(selectedValueY, 2);
ToolTipChart.Show(selectedValueX.ToString() + "°; " + selectedValueY.ToString() + " m", chart0, pos.X, pos.Y - 30);
}
else
ToolTipChart.Hide(chart0);
}
When mouse is over the hidden DataPoints -> ( result.ChartElementType == ChartElementType.Axis ) or (result.ChartElementType == ChartElementType.AxisLabel ) instead.
I tried disabling the axis, then reading the mouse position, then enabling the axis, but it's too slow and the user does see blinking of the axis on the screen.
Is there a way to move the "DataPoint layer" on top of the chart so it's not under the "Axis layer"?
Ilustration of hidden DataPoints:
Theres is a function overload Chart.HitTest Method (Int32, Int32, ChartElementType)
where you can filter for the desired ChartElementType.
http://msdn.microsoft.com/en-us/library/dd467907%28v=vs.110%29.aspx