Selecting point in FreeformPointLineSeries

Need help in implementing some specific function to your LightningChart Ultimate powered application? Post a question and get code snippets from other LightningChart Ultimate community members.

Selecting point in FreeformPointLineSeries

Postby ludur » Tue Apr 09, 2019 8:39 am

Hello,

I have FreeformPointLineSeries in semibindable-WPF with settings LineVisible="False" PointsVisible="True", an I would like to Select a Point in the chart, so that I can react on the selected point changed, and perform some action when user selects a point. Could you please help me how to do it?
ludur
 
Posts: 1
Joined: Tue Apr 09, 2019 8:35 am

Re: Selecting point in FreeformPointLineSeries

Postby Arction_LasseP » Tue Apr 09, 2019 12:16 pm

Hello,

The best way to do this is to use mouse events and SeriesEventMarkers as done in one of our demo examples, "Value tracking with markers" (ExampleDataPointTracking). You need to set a marker for each series point and then add a mouse event, for example MouseClick, to that marker. You can then define the action inside the event.

Here is an example code:

Code: Select all
         SeriesPoint[] points = new SeriesPoint[pointCount];
         Random rand = new Random();
         for (int i = 0; i < pointCount; i++)
         {
            points[i].X = 50 + (rand.NextDouble() - 0.5) ;
            points[i].Y = i;
         }
         freeformPointLineSeries.Points = points;
         _chart.ViewXY.FreeformPointLineSeries.Add(freeformPointLineSeries);

         //Add marker for each point, to act as an editing point
         for (int i = 0; i < pointCount; i++)
         {
            SeriesEventMarker marker = new SeriesEventMarker(freeformPointLineSeries);
            marker.XValue = points[i].X;
            marker.YValue = points[i].Y;

            //store values in label text
            marker.Label.Text = points[i].X.ToString("0.0") + " ; " + points[i].Y.ToString("0.0");
            marker.Label.Visible = false;

                                marker.MouseClick += new MouseEventHandler(Marker_MouseClick);
            freeformPointLineSeries.SeriesEventMarkers.Add(marker);
         }

        private void Marker_MouseClick(object sender, MouseEventArgs e)
        {
            ((SeriesEventMarker)sender).Label.Visible = true;
        }
Arction_LasseP
 
Posts: 28
Joined: Wed Mar 27, 2019 1:05 pm


Return to LightningChart Ultimate How-To's

Who is online

Users browsing this forum: No registered users and 1 guest