Search code examples
zedgraph

Format DateAsOrdinal xAxis labels in ZedGraph


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.

enter image description here


Solution

  • Fixed this by formatting each label individually.