Search code examples
c#wpfoxyplot

Can I draw vertical lines on the LineSeries Graph?


I'm making an application with some OxyPlot Graphs.

I want to make a graph that has a vertical line on the LineSeries Graph like this link:

http://theclosetentrepreneur.com/how-to-add-a-vertical-line-to-an-excel-xy-chart

(My ideal image is in "Tips on formatting your chart…".)

How can I make this graph?


Solution

  • You can make use of LineAnnotation for the purpose. For example,

    var annotation = new LineAnnotation();
    annotation.Color = OxyColors.Blue;
    annotation.MinimumY = 10;
    annotation.MaximumY = 40;
    annotation.X = 5;
    annotation.LineStyle = LineStyle.Solid;
    annotation.Type = LineAnnotationType.Vertical;
    MyPlotModel.Annotations.Add(annotation);
    

    Sample Output

    enter image description here