【问题标题】:Oxyplot Lineannotation not displayed不显示 Oxyplot Lineannotation
【发布时间】:2019-12-09 13:07:05
【问题描述】:

我将 Oxyplot 与 WPF 和 C# 一起使用

我是 Oxyplot 的新手,想了解如何使用 Lineannotations。

我想在我的绘图模型中添加 2 个 Lineannotations,一个应该是垂直的,另一个应该是水平的。

我的问题是只显示水平 LineAnnotation (annotation2) 而垂直不显示。

代码如下:

var annotation = new LineAnnotation();

annotation.Color = OxyColors.Blue;
annotation.LineStyle = LineStyle.Solid;
annotation.StrokeThickness = 5;
annotation.X = 0;
annotation.Type = LineAnnotationType.Vertical;

Model.Annotations.Add(annotation);


//this works
var annotation2 = new LineAnnotation();

annotation2.Color = OxyColors.Blue;
annotation2.LineStyle = LineStyle.Solid;
annotation2.StrokeThickness = 5;
annotation2.Y = 0;  
annotation2.Type = LineAnnotationType.Horizontal;

Model.Annotations.Add(annotation2);

Model.InvalidatePlot(true);

垂直注释不显示的原因是什么?

【问题讨论】:

    标签: c# oxyplot


    【解决方案1】:

    看起来您的注释位于 Axes 之外。请确保您的 Axes 被定义为注释行在其中。

    以下声明将确保 Annotation(上面声明)与 Axes 处于相同位置。

    Model.Axes.Add(new OxyPlot.Axes.LinearAxis
    {
       Position = Axes.AxisPosition.Bottom,
       Minimum = 0
    });
    
    Model.Axes.Add(new OxyPlot.Axes.LinearAxis
    {
       Position = Axes.AxisPosition.Left,
       Minimum = 0
    });
    

    【讨论】:

      猜你喜欢
      • 2021-12-28
      • 2016-01-15
      • 1970-01-01
      • 2017-10-29
      • 1970-01-01
      • 2018-04-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多