如何更改ZedGraph Xaxis中的时间范围?
我需要在 zedgraph 上有多个时间范围。我必须在每日时间范围内显示股票数据,然后如果用户希望在每月时间范围或每小时时间范围内查看视图,我需要支持它。请注意,数据必须位于蜡烛条中,而不是折线条中。
目前我有 3 条曲线,一次只显示一条并隐藏其他曲线。例如,最初我将图表设置为每日时间范围,并隐藏小时和每月时间范围蜡烛棒曲线。当用户发出查看每小时图表的命令时,我隐藏每日烛台并显示每小时时间图表。但是我无法更改 x 轴,因为它仍然显示每日时间而不是更改为每小时。我需要做一些事情来将 x 轴时间范围从每天更改为每小时。
任何形式的帮助都是值得赞赏的。即使有解决方法,也请告知。谢谢。
I need to have multiple time frame on a zedgraph. I have to display the stock data on a daily time frame and then if user wishes to view the view in monthly time frame or hourly time frame i need to support it. Note that the data must be in candle stick bar and not the line bar.
Currently i have 3 curves and i display only one at a time and hide the others. For example initially i set up my graph to be on daily time frame and hide the hour and monthly time frame candle stick curve. When the user gives the command to see the hourly graph i hide the daily candle stick and show the hourly time graph. However i am not able to change the x axis as it still shows the daily time instead of changing to hourly. I need to do something to change the x axis time frame from daily to hourly.
Any kind of help is appreciable. Please advise even if there is a workaround. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能可以通过更改
XAxis.Scale
对象的Min
、Max
和Step
属性来实现。因此,支持此用户操作的方法/事件处理程序应该:
- 在窗格中显示/隐藏正确的曲线,更改
- 使用上面列出的属性调整比例
- 刷新图表。
请注意,ZedGraphControl 的
Refresh()
方法并不便宜。它会重新绘制图表上的所有元素,因此如果您有大量数据,那么使用它并不是一个好主意。在这种情况下,您应该结合使用 AxisChange() 和 Invalidate() 方法。它应该更快、更便宜。
You probably can do it by changing
Min
,Max
andStep
properties ofXAxis.Scale
object.So, your method/event handler that supports this user action should:
- show/hide proper curves at pane, change
- adjust the scale using properties I listed above
- refresh the graph.
Note, that
Refresh()
method of ZedGraphControl isn't cheap. It redraws all elements on your graph, so if you have a lot of data, it isn't good idea to use it.In that situation you should use combination of
AxisChange()
andInvalidate()
methods. It should be faster and cheaper.