2015-08-28 38 views
1

任何人都可以请告诉如何在Oxyplot的行系列的数据点中添加一个字符串值?在Oxyplot行系列的数据点中添加一个字符串值

我有一个列表,它是一个字符串的键值对,double,并希望将它添加到数据点。

例: 字符串值是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))); 
} 

回答

4

只是用PointAnnotation

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

     } 

请看注释下的Oxyplot Example Browser

+0

谢谢。这段代码拯救了我的生命! – naffie

相关问题