C# 中的实时绘图

发布于 2024-10-17 08:09:50 字数 343 浏览 2 评论 0原文

我正在尝试使用 c# 和 windows mobile 5 在通过蓝牙串行端口实时收集的 PDA 上绘制数据。我在以看起来平滑的方式绘制数据时遇到问题。我尝试从一组点中画一条线,该线有效,但只真正显示离散的数据块。我在这个论坛上参考心电图数据找到了一个类似的解决方案,该解决方案也有效,但它再次显示了一些数据,然后非常明显地刷新了。我尝试将点绘制到位图上,然后绘制位图以使其更平滑,但它又不够快。

我希望最终得到的行为类似于 Windows 任务管理器中的 CPU 使用历史图。数据点从图的右侧开始,并平滑地移动到左侧。是否有解决此类问题的标准方法?如果问题有点模糊,我深表歉意,但如果这是一个众所周知的通用解决方案的问题,我不想花很长时间尝试不同的事情。

I am trying to plot data on a PDA that is being collected in real time via the bluetooth serial port using c# and windows mobile 5. I am having trouble plotting the data in such a way that it appears smooth. I have tried drawing a line from an array of points which worked but only really displayed discrete chunks of data. I found a similar solution on this forum in reference to ECG data, which also worked but again it showed some amount of data and then very visibly refreshed. I have tried drawing the points onto a bitmap and then painting the bitmap to make it smoother but again it isn't really fast enough.

What I would like to end up with is something that behaves like the CPU usage history graph in the windows task manager. A data point starts on the right hand side of the plot and moves smoothly across to the left. Is there a standard approach to a problem like this? I apologise if the question is a little vague but I don't want to spend ages trying different things if its a problem with a well known general solution.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

听风念你 2024-10-24 08:09:50

这在某种程度上取决于您希望它如何在视觉上发挥作用。任务管理器中的CPU使用率将整个图表从右向左滚动,而且一点也不平滑。它大约每秒刷新一次(无论如何对我来说),当它刷新时,整个图表就会“撞”到一边。

我在 1.0 的日子里在 CF 中做了一些测试,我选择让图表保持静态,并不断从左到右绘制数据线,当它到达右边缘时,它将再次开始绘制回到向左,随着它的进展擦除最旧的图表数据(就像心电图一样)。

对于这种情况,您的位图基本上保持不变,因此您不应该重新绘制整个内容。我通过使用基本上是“垂直带”或图表高度的矩形但只有 10 像素宽的剪切区域来完成此操作。我用更新的轴值重新绘制了该带,因此实际重绘的唯一位是那个小带。它还有一个额外的好处,就是当我回到图表的开头时,可以明显地“删除”最旧的数据。

It kind of depends on how you want it to work visually. The CPU usage in Task Manager scrolls the entire chart right to left, and it is not at all smooth. It's refreshing (for me anyway) about once a second and when it refreshes, then entire chart "bumps" to the side.

I did something in the CF back in the 1.0 days as a test, and I opted to have the chart remain static and have the data lines continuually drawn left to right and when it reached the right edge, it would start drawing again back on the left, erasing the oldest chart data as it progressed (like an ECG does).

For that scenario, your bitmap is remaining largely unchanged, so you shouldn't be redrawing the entire thing. I did this by using a clipping resion that was basically a "vertical band" or rectangle the height of the chart but only, say, 10px wide. I redrew that band with the updated axis values so the only bits actually being redrawn is that small band. It also had the added benefit of doing the visible "erasing" the oldest data once I wrapped back to the start of the chart.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文