wpf工具包散点图
我从来没有对这个 wpf 工具包如此恼火。文档根本不存在!啊。
究竟如何连接散点图中的线条?
我需要生成一个跨多个系列的线性图。我使用 Excel 散点图很好地制作了我需要做的事情的原型,但我一生都无法弄清楚如何连接工具包中的点。
这是代码,我是否缺少一个选项?
<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)
};
I have never been so annoyed with this wpf toolkit. The documentation is just not there! argh.
How on earth can you connect the lines in a scatter chart?
I need to produce a graph that is linear across multiple series. I prototyped what I need to do using Excels scatter chart just fine, but for the life of me I cannot figure out how to connect the dots in the tool kit.
Here is the code, am I missing an option?
<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)
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
散点图不将点与线连接起来。使用 LineSeries 应该将这些点连接起来。
a scatter plot does not connect dots with lines. using a LineSeries instead should connect the dots.