2015-08-28 19 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

相關問題