1、Nuget安装InteractiveDataDisplay.NetCore.WPF,可以看到基于.Net5和System.Reactive
2、在窗口引入控件xmlns:d3="clr-namespace:InteractiveDataDisplay.WPF;assembly=InteractiveDataDisplay.WPF"
3、撰写界面代码,直接书写了LineGraph,代码中引用即可绘制
<d3:Chart Grid.Row="2" Grid.Column="1" IsAutoFitEnabled="True">
<d3:LineGraph x:Name="cChart_LineGraph" />
</d3:Chart>
4、撰写代码
new Thread(() =>
{
Dispatcher.BeginInvoke(new Action(() =>
{
List<double> xs = new List<double>();
List<double> ys = new List<double>();
for(int i = 0; i < 100; i++)
{
double x = i;
double y = rnd.NextDouble();
xs.Add(x);
ys.Add(y);
}
cChart_LineGraph.Plot(xs, ys);
}));
}).Start();