【问题标题】:Adding a string value in datapoint of line series of Oxyplot在 Oxyplot 线系列的数据点中添加字符串值
【发布时间】:2015-08-28 11:14:37
【问题描述】:

谁能告诉如何在 Oxyplot 的线系列数据点中添加字符串值?

我有一个列表,它是字符串的键值对,双精度,想将它添加到数据点。

示例: 字符串值为 10-15,15-20, ...

双精度值是 10、20、30、...

我希望我的 x 轴刻度点显示为例如(10-15、15-20 等)

以下是代码:

foreach (var points in list)
{
   lineseriesobject.Points.Add(new OxyPlot.DataPoint(Convert.ToDouble(points.Key), Convert.ToDouble(points.Value)));
}

【问题讨论】:

    标签: c# oxyplot


    【解决方案1】:

    只需使用PointAnnotation

    foreach (var points in list)
    {
      var pointAnnotation = new PointAnnotation()
      {
        X = Convert.ToDouble(points.Key),
        Y = Convert.ToDouble(points.Value),
        Text = String.Format("{0}-{1}",points.Key,points.Value)
      });
      lineSeriesObject.Points.Add(new OxyPlot.DataPoint(Convert.ToDouble(points.Key), Convert.ToDouble(points.Value)));
      plotModelObject.Annotations.Add(pointAnnotation);
    }
    plotModelObject.Series.Add(lineSeriesObject);
    

    只需查看注释下的OxyPlot Example Browser

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-11
      相关资源
      最近更新 更多