Preferable way to add new points to chart
Posted: Mon Feb 05, 2024 10:45 am
Hi,
as I understand, there are different possibilities to add points to a chart.
One of your demos show that you can define a binding in xaml code to a dependency property defined in the corresponding data context/view model. Adding points to the binding property leads to an automatic update of the chart.
In my use case, I don't know how many different series will be needed, therefore I have to add them in code-behind and not in the xaml. In this case I update the points collection by code like this:
ChartViewXY.PointLineSeries[0].Points = chartControlViewModel.SeriesPoints
This seems to be a way which is also used in your demos. Is this way more or less performant than using a xaml-binding? And does it make a difference if I replace the Points collection like in the code above or instead using PointLineSeries[0].AddPoints()?
as I understand, there are different possibilities to add points to a chart.
One of your demos show that you can define a binding in xaml code to a dependency property defined in the corresponding data context/view model. Adding points to the binding property leads to an automatic update of the chart.
In my use case, I don't know how many different series will be needed, therefore I have to add them in code-behind and not in the xaml. In this case I update the points collection by code like this:
ChartViewXY.PointLineSeries[0].Points = chartControlViewModel.SeriesPoints
This seems to be a way which is also used in your demos. Is this way more or less performant than using a xaml-binding? And does it make a difference if I replace the Points collection like in the code above or instead using PointLineSeries[0].AddPoints()?