Search code examples
zedgraph

ZedGraph Axis labels


I have two questions about axis labels:

  1. How do I make a label at the Y2-axis, that shows a highlighted label following the dynamic price (y2-value) of the last bar/candlestick? As the red label in this example:

enter image description here

And possibly also the same on the XAxis, showing the time of the last bar.

  1. Also I wonder how to make the time axis plot only every 30 min, and also that it should be full half hours, not arbitrary 30 min spots.. As also shown in the above image.

ZedGraph is awesome. But takes some time to figure out the tricks and tweaks.. :)


Solution

  • Ad. 1. You probably need to create a custom text object. If I remember correctly:

    TextObj label = new TextObj("some text", 1, y2coordinate);              
    label.Location.CoordinateFrame = CoordType.XChartFractionY2Scale;
    label.Location.AlignH = AlignH.Left;
    myPane.GraphObjList.Add(label);
    

    to change the color and background, just edit properties of label.FontSpec

    Ad. 2. You need to set manualy the Min, Max and MajorStep of the Scale object of your axis.