WPF 中的简单滚动图形图表

本文关键字:滚动 图形图表 简单 WPF | 更新日期: 2023-09-27 18:30:38

在我的程序中,我每秒在调度程序中轮询一次以接收当前的网络吞吐量:

private PerformanceCounter netSndCounter =
    new PerformanceCounter("Network Interface", "Bytes Sent/sec");
private PerformanceCounter netRcvCounter =
    new PerformanceCounter("Network Interface", "Bytes Received/sec");
private void updateTimer(object sender, EventArgs e)
{
    netSndCurrent = netSndCounter.NextValue();
    netRcvCurrent = netRcvCounter.NextValue();
}

这运行良好...但是,我想以某种方式将其显示为图表。类似于您在性能选项卡中的 Windows 任务管理器中看到的图形。我可以使用任何简单而轻量级的工具来完成此操作吗?

有没有没有第三方库的好方法?

WPF 中的简单滚动图形图表

可以使用 WPF 类ChartPlotter来制作图形。

有关一些示例,请参见:C# WPF 应用程序中的 msdn 和动态折线图

或者,如果你想要一些第三方库,你可以看看这篇文章:WPF图表控件