在 oxyplot 中居中轴

3

我希望用Oxyplot绘制类似下面的图表,问题是我不知道如何在值为50处绘制带有值的轴。

example

代码:

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

这就是它的样子

enter image description here

1个回答

1
不确定您是否想要这样做,但是添加


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

将以下设置代码添加到您的代码中将会产生这个效果。

enter image description here


谢谢。虽然不是我想要的完全解决方案,但它解决了问题。我想在中心(50)绘制左侧和底部轴...你能帮我做另一件事吗?有没有办法不在较大的椭圆注释外呈现网格线? - behrooz
@behrooz 很高兴能帮到你。我不确定你的意思。你能否制作一张图片并展示/描绘你的意思?如果你将其发布为一个新问题,其他人也可以从中受益。 - dd4711
好的,我提了一个新问题链接 - behrooz
@behrooz 我看了一下,但不幸的是我不知道如何实现。但还是谢谢你的认可 ;) - dd4711

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接