图表控制 Y 轴滚动时自动缩放
我已经在网上搜索了一段时间,但仍然没有找到任何好的解决方案来解决我的问题。我想让 MS Chart 在滚动时自动重新缩放 Y 轴,以确保所有数据点都可见。这里的问题是我需要能够排除某些系列用于自动缩放。到目前为止,我只找到了可以在 AxisViewChanged 事件上迭代整个点集合的解决方案,当您有大量点集合和几个要迭代的系列时,该解决方案效果不佳。我想知道是否有任何方法可以通过获取当前可见的最小和最大 X 值之间的数据点来缩小搜索范围。任何帮助将不胜感激。
编辑 这是图像。正如您所看到的,中间的烛台并不完全可见。
I've been searching the net for some time now yet still haven't found any good solution to my problem. I want to make MS Chart to automatically rescale Y axis on scrolling to make sure that all data points are visible. The twist here is that I need to have the ability to exclude certain series from being used for auto scale. So far I only found solutions that offer to iterate through the entire point collection on AxisViewChanged event, which doesn't work well when you have large collections of points and a few series to iterate through. I was wondering if there was any way to narrow the search by obtaining data points that are between currently visible min and max X values. Any help would be appreciated.
Edit Heres the image. As you can see the candlesticks in the middle aren't entirely visible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
你可以尝试这个代码
you can try this code
使用查询找出要使用哪个系列来查找代码中的 ymin 和 ymax。
Use a query to find out which series you want to use for finding ymin and ymax in the code.
这是对 Shivaram KR 提交的优秀提交的一个小改进,以防止金融图表上具有四个 Y 值的最低点的开盘价、收盘价和低点跌落底部:最高价、最低价、开盘收盘价。
This is a minor improvement on the excellent submission from Shivaram K R, to prevent open, close and low dropping off the bottom for the lowest points on financial charts with four Y values: high, low, open close.
根据之前的答案,
图表区域中可能有更多系列。在这种情况下,您可以选择该区域中所有系列的最高价和最低价,而不仅仅是一个系列。
问候,
马泰斯
Based on previous answers
It could be you have more series in the chartarea. In this case you pick the high and low of all series in the area instead of just one.
regards,
Matthijs
上面的回答对我来说非常有帮助。但是,我有一个包含多个图表区域的图表。我已经调整了代码以扩展到所有图表区域:
Above answers were very helpful for me. However, I have a chart with multiple charting areas. I have adapted the code to scale up to all chart areas: