I want to display a large collection of points as a chart (at least 300 000 points), using wpf toolkit chart.
I have the following XAML
<chartingToolkit:Chart Name="chartHistory">
<chartingToolkit:Chart.Axes>
<chartingToolkit:LinearAxis x:Name="horizontalAxis" Orientation="X" Title="Time [s]" ShowGridLines="True"/>
<chartingToolkit:LinearAxis x:Name="verticalAxis" Orientation="Y" Title="Value [mm]" ShowGridLines="True"/>
</chartingToolkit:Chart.Axes>
<chartingToolkit:AreaSeries x:Name="chartSeries" DataPointStyle="{StaticResource chartDataPoint}"
IndependentValuePath="TimeInSeconds"
DependentValuePath="Value">
</chartingToolkit:AreaSeries>
</chartingToolkit:Chart>
And in code behind:
public class PointData
{
public double TimeInSeconds { get; set; }
public double Value { get; set; }
}
private List<PointData> points;
private void Screen_Loaded(object sender, RoutedEventArgs e)
{
// this is a large collection of points (minimum 300 000)
points = LoadPointsFromFile();
// and it takes a lot of time to read from the file and load in the UI
chartSeries.ItemsSource = points;
// additional chart display properties (setting min/max on the axes etc.)
}
So, I have 2 time consuming operations that block my UI. What I want is to display a "please load dialog" while the time consuming operations take place, so that the user knows the application is still doing something.
The time consuming operations are:
- reading the points from the file (this operation could be done on a separate thread, but since the next operation (loading the points in the chart) depends on it and is a UI operation, I didn't put it in a separate thread)
- loading the points as ItemsSource in the chart - this is a UI operation and should be done on the UI thread. But how can I still make the application responsive since I do not have any control on how the points are displayed - this is the chart's own logic?
So, any ideas? Did you have any similar problems? Thank you, Nadia