Center Axes in oxyplot

妖精的绣舞 提交于 2019-12-23 20:26:48

问题


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.

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


回答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



来源:https://stackoverflow.com/questions/44806760/center-axes-in-oxyplot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!