Reputation: 571
I use Oxyplot with WPF and C#
I'm new to Oxyplot and try to understand how to use Lineannotations.
I want to add 2 Lineannotations to my plotmodel, one should be vertical the other horizontal.
my problem ist that only the horizontal LineAnnotation is displayed (annotation2) and the vertical is not displayed.
Here the code:
var annotation = new LineAnnotation();
annotation.Color = OxyColors.Blue;
annotation.LineStyle = LineStyle.Solid;
annotation.StrokeThickness = 5;
annotation.X = 0;
annotation.Type = LineAnnotationType.Vertical;
Model.Annotations.Add(annotation);
//this works
var annotation2 = new LineAnnotation();
annotation2.Color = OxyColors.Blue;
annotation2.LineStyle = LineStyle.Solid;
annotation2.StrokeThickness = 5;
annotation2.Y = 0;
annotation2.Type = LineAnnotationType.Horizontal;
Model.Annotations.Add(annotation2);
Model.InvalidatePlot(true);
what could be the reason that the vertical annotation is not displayed ?
Upvotes: 1
Views: 1813
Reputation: 18155
Looks like your Annotation lies outside the Axes. Please ensure your Axes are defined such that the annotations lines within.
The following declaration would ensure the Annotation (Declared above) would like in same position as Axes.
Model.Axes.Add(new OxyPlot.Axes.LinearAxis
{
Position = Axes.AxisPosition.Bottom,
Minimum = 0
});
Model.Axes.Add(new OxyPlot.Axes.LinearAxis
{
Position = Axes.AxisPosition.Left,
Minimum = 0
});
Upvotes: 3