Issue with "Points Tracking" Example
Posted: Wed Oct 11, 2023 5:11 pm
Hi Arction,
I'm currently running the "Points Tracking" example and have encountered an issue. Specifically, when I move the mouse pointer over a data point, the color of the point doesn't change as expected. I've reviewed the code that handles this behavior and have identified the area that may be causing the problem:
private void _chart_MouseMove(object sender, MouseEventArgs e)
{
_chart.BeginUpdate();
View3D view3D = _chart.View3D;
// Reset highlighted point colors
foreach (PointLineSeries3D pointLineSeries3D in _chart.View3D.PointLineSeries3D)
{
if (pointLineSeries3D.Tag != null)
{
// Restore color
int iPointIndexUsedToBeTargeted = (int)pointLineSeries3D.Tag;
// The issue may be here
pointLineSeries3D.Points[iPointIndexUsedToBeTargeted].Color = Colors.Red;
}
}
Annotation3D targetValueLabel = view3D.Annotations[0];
targetValueLabel.Visible = false;
// Get object under the mouse, if any
object obj = _chart.GetActiveUserInteractiveDeviceOverObject();
if (obj != null)
{
if (obj is PointLineSeries3D)
{
PointLineSeries3D pointLineSeries3D = obj as PointLineSeries3D;
int pointIndex = pointLineSeries3D.LastHitTestIndex;
pointLineSeries3D.Points[pointIndex].Color = ChartTools.CalcGradient(pointLineSeries3D.Title.Color, Colors.White, 50);
pointLineSeries3D.Tag = pointIndex; // Store information about the highlighted point index
SeriesPoint3D point = pointLineSeries3D.Points[pointIndex];
targetValueLabel.TargetAxisValues.SetValues(point.X, point.Y, point.Z);
targetValueLabel.Text = "Series index: " + view3D.PointLineSeries3D.IndexOf(pointLineSeries3D).ToString()
+ "\nPoint index: " + pointIndex.ToString()
+ "\nX=" + point.X.ToString("0.0") + " ; Y=" + point.Y.ToString("0.0") + " ; Z=" + point.Z.ToString("0.0");
targetValueLabel.Fill.Color = ChartTools.CalcGradient(pointLineSeries3D.Title.Color, Colors.White, 90);
targetValueLabel.TextStyle.Color = Colors.Black;
targetValueLabel.Fill.GradientColor = ChartTools.CalcGradient(pointLineSeries3D.Title.Color, Colors.White, 50);
targetValueLabel.Visible = true;
}
}
_chart.EndUpdate();
}
If you have any insights or suggestions to resolve this issue, please let me know.
Thanks.
I'm currently running the "Points Tracking" example and have encountered an issue. Specifically, when I move the mouse pointer over a data point, the color of the point doesn't change as expected. I've reviewed the code that handles this behavior and have identified the area that may be causing the problem:
private void _chart_MouseMove(object sender, MouseEventArgs e)
{
_chart.BeginUpdate();
View3D view3D = _chart.View3D;
// Reset highlighted point colors
foreach (PointLineSeries3D pointLineSeries3D in _chart.View3D.PointLineSeries3D)
{
if (pointLineSeries3D.Tag != null)
{
// Restore color
int iPointIndexUsedToBeTargeted = (int)pointLineSeries3D.Tag;
// The issue may be here
pointLineSeries3D.Points[iPointIndexUsedToBeTargeted].Color = Colors.Red;
}
}
Annotation3D targetValueLabel = view3D.Annotations[0];
targetValueLabel.Visible = false;
// Get object under the mouse, if any
object obj = _chart.GetActiveUserInteractiveDeviceOverObject();
if (obj != null)
{
if (obj is PointLineSeries3D)
{
PointLineSeries3D pointLineSeries3D = obj as PointLineSeries3D;
int pointIndex = pointLineSeries3D.LastHitTestIndex;
pointLineSeries3D.Points[pointIndex].Color = ChartTools.CalcGradient(pointLineSeries3D.Title.Color, Colors.White, 50);
pointLineSeries3D.Tag = pointIndex; // Store information about the highlighted point index
SeriesPoint3D point = pointLineSeries3D.Points[pointIndex];
targetValueLabel.TargetAxisValues.SetValues(point.X, point.Y, point.Z);
targetValueLabel.Text = "Series index: " + view3D.PointLineSeries3D.IndexOf(pointLineSeries3D).ToString()
+ "\nPoint index: " + pointIndex.ToString()
+ "\nX=" + point.X.ToString("0.0") + " ; Y=" + point.Y.ToString("0.0") + " ; Z=" + point.Z.ToString("0.0");
targetValueLabel.Fill.Color = ChartTools.CalcGradient(pointLineSeries3D.Title.Color, Colors.White, 90);
targetValueLabel.TextStyle.Color = Colors.Black;
targetValueLabel.Fill.GradientColor = ChartTools.CalcGradient(pointLineSeries3D.Title.Color, Colors.White, 50);
targetValueLabel.Visible = true;
}
}
_chart.EndUpdate();
}
If you have any insights or suggestions to resolve this issue, please let me know.
Thanks.