1

我从未对这个 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)
};
4

1 回答 1

3

散点图不会将点与线连接起来。使用 LineSeries 应该连接点。

于 2011-02-02T01:35:29.637 回答