2011-02-02 106 views
0

我從來沒有如此討厭這個wpf工具包。文檔不在那裏!哎呀。wpf工具包散點圖

如何在散點圖中連接線?

我需要生成一個跨多個系列的線性圖。我使用Excels散點圖做了什麼我需要做的很好,但對於我的生活,我無法弄清楚如何連接工具包中的點。

這是代碼,我錯過了一個選項?

<my:Chart Name="myChart" Margin="5,5,5,5" Opacity="1" Width="525"> 
</my:Chart> 

ScatterSeries a = new ScatterSeries(); 
a.Title = "a"; 

a.IndependentValuePath = "Key"; 
a.DependentValuePath = "Value"; 
myChart.Series.Add(a); 

a = new ScatterSeries(); 
a.Title = "b"; 
a.IndependentValuePath = "Key"; 
a.DependentValuePath = "Value"; 
myChart.Series.Add(a); 

((ScatterSeries)myChart.Series[0]).ItemsSource = new KeyValuePair<DateTime, int>[] 
{ 
    new KeyValuePair<DateTime, int>(DateTime.Now.AddMonths(1), 0), 
    new KeyValuePair<DateTime, int>(DateTime.Now.AddMonths(2), 150), 
    new KeyValuePair<DateTime, int>(DateTime.Now.AddMonths(3), 150), 
    new KeyValuePair<DateTime, int>(DateTime.Now.AddMonths(4), 0), 
    new KeyValuePair<DateTime, int>(DateTime.Now.AddMonths(5), 0), 
    new KeyValuePair<DateTime, int>(DateTime.Now.AddMonths(8), 130), 
    new KeyValuePair<DateTime, int>(DateTime.Now.AddMonths(9), 130), 
    new KeyValuePair<DateTime, int>(DateTime.Now.AddMonths(10), 0), 
    new KeyValuePair<DateTime, int>(DateTime.Now.AddMonths(11), 0), 
    new KeyValuePair<DateTime, int>(DateTime.Now.AddMonths(15), 225), 
    new KeyValuePair<DateTime, int>(DateTime.Now.AddMonths(16), 225), 
    new KeyValuePair<DateTime, int>(DateTime.Now.AddMonths(17), 0) 
}; 


((ScatterSeries)myChart.Series[1]).ItemsSource = new KeyValuePair<DateTime, int>[] 
{ 
    new KeyValuePair<DateTime, int>(DateTime.Now.AddMonths(-21), 0), 
    new KeyValuePair<DateTime, int>(DateTime.Now.AddMonths(-5), 750), 
    new KeyValuePair<DateTime, int>(DateTime.Now.AddMonths(3), 750), 
    new KeyValuePair<DateTime, int>(DateTime.Now.AddMonths(7), 0), 
    new KeyValuePair<DateTime, int>(DateTime.Now.AddMonths(9), 0), 
    new KeyValuePair<DateTime, int>(DateTime.Now.AddMonths(10), 330), 
    new KeyValuePair<DateTime, int>(DateTime.Now.AddMonths(19), 330), 
    new KeyValuePair<DateTime, int>(DateTime.Now.AddMonths(20), 0), 
    new KeyValuePair<DateTime, int>(DateTime.Now.AddMonths(21), 0), 
    new KeyValuePair<DateTime, int>(DateTime.Now.AddMonths(25), 525), 
    new KeyValuePair<DateTime, int>(DateTime.Now.AddMonths(26), 525), 
    new KeyValuePair<DateTime, int>(DateTime.Now.AddMonths(27), 0) 
}; 

回答

3

散點圖不會將點與線連接起來。使用LineSeries應該連接點。

+0

那麼,這解決了問題!非常感謝。 – nitefrog 2011-02-02 01:55:47