本文介绍了oxyplot中的中心轴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用oxyplot绘制如下图所示的图表,问题是我不知道如何绘制值为50的轴(带有值)。

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.

代码:

        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 });

这就是它的样子

推荐答案

不确定这是否是您想要的,但要添加

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

这篇关于oxyplot中的中心轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 22:27