Format DateAsOrdinal xAxis labels in ZedGraph

匿名 (未验证) 提交于 2019-12-03 00:59:01

问题:

I have now changed my x axis to DateAsOrdinal, but I would like to improve the label format. I currently handle the XAxis.ScaleFormatEvent like this:

Private Function OnXScaleFormatEvent(ByVal pane As GraphPane, ByVal axis As Axis, ByVal val As Double, ByVal index As Integer) As String     Dim result As String = ""     If val < priceBars.Count Then         Dim time As Date = Date.FromOADate(priceBars(val).X)         result = [String].Format("{0:D2}{1}{2:D2}", time.Hour, ":", time.Minute)     End If      Return result End Function 

How can I make the labels only print every whole 30 minutes? Or every 2 hours as in image below? I believe I still need to reference the bar x-values, because I need to plot multiple days continuously, with only some hours from each day, like the image shows; 09:00-23:00.

http://i53.tinypic.com/2jcwknd.png

回答1:

I think, this will do:

chart.GraphPane.XAxis.Scale.MajorStepAuto = False chart.GraphPane.XAxis.Scale.MajorUnit = DateUnit.Minute chart.GraphPane.XAxis.Scale.MajorStep = 30 chart.GraphPane.XAxis.Scale.BaseTic = 0 


回答2:

Fixed this by formatting each label individually.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!