3

I want to draw a chart like image below with oxyplot, the problem is i don't know how to draw axis (with values) at value 50.

example

Code :

        var model = new PlotModel { Title = "EllipseAnnotations" };
        model.Axes.Add( new LinearAxis {
            Position = AxisPosition.Bottom,
            Minimum = 20,
            Maximum = 80,
            PositionAtZeroCrossing = true,
            ExtraGridlines = new[] { 50.0 },
            ExtraGridlineStyle = LineStyle.Dash
        });
        model.Axes.Add(new LinearAxis {
            Position = AxisPosition.Left,
            Minimum = 20,
            Maximum = 80,
            PositionAtZeroCrossing = true,
            ExtraGridlines = new[] { 50.0 }
        });
        model.Annotations.Add(new EllipseAnnotation { X = 50, Y = 50, Width = 10, Height = 10, Fill = OxyColors.LightGray, Stroke = OxyColors.Black, StrokeThickness = 1 });
        model.Annotations.Add(new EllipseAnnotation { X = 50, Y = 50, Width = 30, Height = 30, Fill = OxyColors.Transparent, Stroke = OxyColors.Black, StrokeThickness = 1 });
        model.Annotations.Add(new EllipseAnnotation { X = 50, Y = 50, Width = 60, Height = 60, Fill = OxyColors.Transparent, Stroke = OxyColors.Black, StrokeThickness = 1 });

        //model.Annotations.Add(new EllipseAnnotation { X = 50, Y = 50, Width = 20, Height = 20, Fill = OxyColors.Aqua, Stroke = OxyColors.Black, StrokeThickness = 2 });
        //model.Annotations.Add(new EllipseAnnotation { X = 30, Y = 20, Width = 20, Height = 20, Fill = OxyColors.Red, Stroke = OxyColors.Black, StrokeThickness = 2 });
        //model.Annotations.Add(new EllipseAnnotation { X = 25, Y = 30, Width = 20, Height = 20, Fill = OxyColors.Blue, Stroke = OxyColors.Black, StrokeThickness = 2 });

and this is how it look

enter image description here

behrooz
  • 617
  • 9
  • 30

1 Answers1

1

Not sure if this is what you intend, but adding

        model.Annotations.Add(new TextAnnotation
        {
            TextPosition = new DataPoint(50, 50),
            Text = "50",
            TextHorizontalAlignment = HorizontalAlignment.Center,
            TextVerticalAlignment = VerticalAlignment.Middle,
            StrokeThickness = 0
        });

to your setup code will produce this

enter image description here

dd4711
  • 789
  • 6
  • 18
  • Thank you. that is not what i was exactly looking for but it solve the problem. i wanted to draw left and bottom axes at center (50) ... Could you help me with another thing ? Is there a way that don't render the gridline outside the larger EllipseAnnotation ? – behrooz Jun 29 '17 at 13:16
  • @behrooz Glad I could help. I'm not sure what you mean. Could you make an image and show/paint what you mean? If you post that as a new question others may benefit from it too. – dd4711 Jun 29 '17 at 13:25
  • ok i asked new question [link](https://stackoverflow.com/questions/44826731/how-to-dont-render-gridline-outside-ellipseannotation-in-oxyplot) – behrooz Jun 29 '17 at 13:38
  • @behrooz I had a look but unfortunaltely I have no idea how to achieve that. But thank you for the credits ;) – dd4711 Jun 30 '17 at 08:51