2017-06-28 50 views
3

我想画样图像的图表下面oxyplot,问题是我不知道如何在价值50中心轴在oxyplot

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

不知道这是否是你想要什么,但加入

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

您的设置代码将产生此

enter image description here

+0

谢谢。这不是我正在寻找的东西,但它解决了这个问题。我想在中心(50)画出左右轴......你能帮助我解决另一个问题吗?有没有办法在更大的EllipseAnnotation之外渲染网格线? – behrooz

+0

@ behrooz很高兴能帮到你。我不确定你是什么意思。你可以制作一张图片并展示/描绘你的意思吗?如果您将其作为新问题发布,其他人也可能从中受益。 – dd4711

+0

谢谢你,我会发布新的问题与形象 – behrooz