fat
fat

Reputation: 7133

Is it possible to create zedgraph vertical marker?

I wonder, is it possible to create vertical marker in zedgraph?
I want to render all chart points and make vertical marker as indicator of current position.

Upvotes: 3

Views: 3823

Answers (2)

Anders Gustafsson
Anders Gustafsson

Reputation: 15981

You can set the SymbolType of your curve to SymbolType.VDash.

For example, to set the symbol for a LineItem, you can either do it directly in the constructor (curve1 in the source code below), or you can customize it before assigning it to the curve (curve2).

This code:

var curve1 = new LineItem(null, new[] { 0.1, 0.5, 0.9 }, 
             new[] { 0.8, 0.3, 0.1 }, Color.Blue, SymbolType.VDash);
zedGraphControl1.GraphPane.CurveList.Add(curve1);

var curve2 = new LineItem(String.Empty)
    {
        Points = new PointPairList(
                 new[] { 0.1, 0.5, 0.9 }, new[] { 0.2, 0.5, 0.9 }),
        Color = Color.Red,
        Symbol = new Symbol(SymbolType.VDash, Color.Black) 
                 { Size = 20f, Border = new Border(Color.Black, 6f)}
    };
zedGraphControl1.GraphPane.CurveList.Add(curve2);

produces the following graph:

Non-customized and customized markers

Upvotes: 1

JonC
JonC

Reputation: 978

On a previous project, I used the following code to get that kind of effect.

int i = myPane.AddYAxis("");
myPane.YAxisList[i].Color = Color.Orange;
myPane.YAxisList[i].Scale.IsVisible = false;
myPane.YAxisList[i].MajorTic.IsAllTics = false;
myPane.YAxisList[i].MinorTic.IsAllTics = false;
myPane.YAxisList[i].Cross = pointOnXAxisThatIWantToMark;

In this case I add two axis to mark certain limits on my graph.

enter image description here

Upvotes: 4

Related Questions