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.
Issue with "Points Tracking" Example
Moderator: Queue Moderators
-
- Posts: 558
- Joined: Mon Mar 14, 2016 9:22 am
Re: Issue with "Points Tracking" Example
For setting customized highlighting this way you need 2 things.
First, you should enable IndividualPointColors property
Second, once you change non-property filed in LightningChart (like Points[pointIndex].Color), you should also 'tell' chart to recreate data by calling InvalidateData()
By the way, if you are using code excerpt from our Demo's ExamplePointTracking3D, it maybe incomplete. That is, as far I could see color is not restored once mouse moves away from 3D-point.
First, you should enable IndividualPointColors property
Code: Select all
pointLineSeries3D.IndividualPointColors = true; //allow each point to have its own color
Code: Select all
if (pointLineSeries3D.Tag != null)
{
//Restore color
int pointIndex = (int)pointLineSeries3D.Tag;
pointLineSeries3D.Points[pointIndex].Color = pointLineSeries3D.Title.Color;
pointLineSeries3D.InvalidateData();
}