2014-12-05 28 views
0

我需要格式化BarItem中的標籤,以便它可以具有時間格式,如00:10。 我正在使用BarSeries.Format函數,但如果我不使用BarSeries.LabelFormatString標籤不顯示,如果我使用LabelFormatString所有標籤將具有相同的格式/值。Oxyplot BarSeries格式函數

這裏是我的代碼:

BarItem baritem = new BarItem {Value = 10}; //in seconds 
Object[] time = new object[2]; 
time [0] = "00"; 
time [1] = "10"; 
barSeries.Format("{0}:{1}",baritem,time); 

有了這個代碼,也沒有任何標籤。使用barSeries.LabelFormatString = "{0}"顯示10

我試過barSeries.LabelFormatString = barSeries.Format("{0}:{1}",baritem,time)但隨後的所有標籤成爲同...

回答

0

對於有人有同樣的問題,解決方法很簡單,只要繼承了BarItem類,如下所示:

class TimeBarItem : BarItem { 
    public TimeSpan Time { get { return TimeSpan.FromSeconds(this.Value); } } 
} 

之後,我們可以這樣做: barSeries.LabelFormatString = "{Time}"