绘制曲线
<dxc:ChartControl Grid.Row="1">
<dxc:XYDiagram2D EnableAxisXNavigation="True">
<dxc:LineSeries2D x:Name="series" CrosshairLabelPattern="{}{A} : {V:F2}"/>
</dxc:XYDiagram2D>
</dxc:ChartControl>
Dispatcher.BeginInvoke(new Action(() =>
{
Random random = new Random();
series.Points.BeginInit();
series.Points.Clear();
for (int i = 0; i < 100000; i++)
series.Points.Add(new SeriesPoint((double)i, random.NextDouble()));
series.Points.EndInit();
}), DispatcherPriority.Background);
执行的结果图标很卡,一样的代码和dev express的demo性能差距很大
窗口不要最大化,窗口太大显示效率明显降低,devexpress demo最大化之后也存在这个问题。
dotnet中绘图可以使用scottplot,基于opengl比livechart的基于skia效率高很多
nuget安装scottplot.wpf
xmlns:sp="clr-namespace:ScottPlot;assembly=ScottPlot.WPF"
...
<sp:WpfPlot Grid.Row="1" Name="series"></sp:WpfPlot>
Random random = new Random();
double[] pointCollection = new double[100000];
Parallel.For(0, 1, (i) =>
{
for (int j = 0; j < pointCollection.Length; j++)
pointCollection[j] = random.NextDouble();
});
series.Plot.AddSignal(pointCollection);
series.Refresh();