Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
360
Moving points on a polyline chart
posted

I would like to create a chart with polylines that I can move the points after the chart is created.

I looked at the "Updating Data Points" sample in the WPF Sample Browser for WPF 23.2 as an example, but I would like to do this with disconnected lines.

I have looked at the XamDataChart ScatterPolylineSeries and the XamShapeChart with Polyline chart type. Both of these take a System.Windows.Point. Point doesn't implement INotifyPropertyChanged, so modifying them does not change the chart.

I tried implementing the ObservableDataPoint class in the example, but the charts won't display the data unless it's a System.WIndows.Point.

Is there a way to accomplish this?

I'm using .NET 8.

Parents
  • 34790
    Verified Answer
    Offline posted

    Hello Josh,

    My best recommendation to “move” the ScatterPolylineSeries would be to replace an existing Point in the underlying ShapeMemberPath’s collection to a new instance of a Point because as you mentioned, the X and Y properties of System.Windows.Point do not implement INotifyPropertyChanged. After doing this, you can call the ScatterPolylineSeries’ RenderSeries method and it will re-render with the change. I believe something along the lines of the following may help you, where the “Points” collection is the ShapeMemberPath of the ScatterPolylineSeries:

                Point point = vm.Data[0].Points[50];
                point.Y = 80;

                Point newPoint = new Point(point.X, 80);

                vm.Data[0].Points.Remove(point);
                vm.Data[0].Points.Insert(50, newPoint);

                chart.Series[0].RenderSeries(false);

    Please let me know if you have any other questions or concerns on this matter.

Reply Children
No Data