列栏+线系列,图表中的排序问题 [英] columnbar + lineseries, sorting problem in chart

查看:92
本文介绍了列栏+线系列,图表中的排序问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我的图表存在问题,我想尝试输入栏,并在其上添加一个线系列.

列栏的示例数据
X:"2010 12" Y:10
X:"2011 01" Y:20
X:"2011 02" Y:30
X:"2011 03" Y:40
X:"2011 04" Y:40
X:"2011 05" Y:30

lineseries
X:"2010 12" Y:14
X:"2011 05" Y:30

XAML

Hello, i have a problem with my chart i want to att columnbars and on top of that a lineseries.

sample data for columnbar
X: "2010 12" Y: 10
X: "2011 01" Y: 20
X: "2011 02" Y: 30
X: "2011 03" Y: 40
X: "2011 04" Y: 40
X: "2011 05" Y: 30

lineseries
X: "2010 12" Y: 14
X: "2011 05" Y: 30

XAML

<chartingToolkit:ColumnSeries x:Name="GoodPercent"
                              Title="Good"
                              ItemsSource="{Binding}"
                              IndependentValuePath="Period"
                              DependentValuePath="Percent" DataPointStyle="{StaticResource ColumnDataPointStyleOfficeGreen}" / >
<chartingToolkit:LineSeries x:Name="Trendline" Title="Trend - satisfied"
                            ItemsSource="{Binding}"
                            IndependentValuePath="Period"
                            DependentValuePath="Number" />



代码隐藏
ColumnSeries cs1 = ScoreInPercentChart.Series [0] as ColumnSeries;
cs1.ItemsSource = e.Result.Where(res => res.ord.Value == 1);

LineSeries ls = ScoreInPercentChart.Series [1] as LineSeries;
ObservableCollection< Trend> myTrend = new ObservableCollection< Trend>();
myTrend.Add(新趋势{期间="2010 12",数字= 85.3});
myTrend.Add(新趋势{期间="2011 05",数字= 60.5});
ls.ItemsSource = myTrend;


我的问题是,当我在代码后面的代码中添加线系列时,x轴的排序错误了

2010 12
2011年05月
2011 01
2011 02
2011 03
2011 04

如果我将线系列放在底部,它会正确显示,但是它会隐藏在列栏的后面.

有没有一种方法可以正确地对图表进行排序,我希望将线系列放置在顶部.

我已经用谷歌搜索,但是在同一张图表中同时处理列栏和线系列时,我没有找到具体的答案.

有人可以帮忙吗?



CODE BEHIND
ColumnSeries cs1 = ScoreInPercentChart.Series[0] as ColumnSeries;
cs1.ItemsSource = e.Result.Where(res => res.ord.Value == 1);

LineSeries ls = ScoreInPercentChart.Series[1] as LineSeries;
ObservableCollection<Trend> myTrend = new ObservableCollection<Trend>();
myTrend.Add(new Trend { Period = "2010 12", Number = 85.3 });
myTrend.Add(new Trend { Period = "2011 05", Number = 60.5 });
ls.ItemsSource = myTrend;


my problem is that when i add the lineseries in codebehind my chart is sorting the xaxis wrong

2010 12
2011 05
2011 01
2011 02
2011 03
2011 04

if i place the lineseries at the bottom it displays correctly, but then it´s hidden behind the columnbars.

is there a way to sort the chart correctly, i want the lineseries to be placed on top.

i have googled but i haven''t found a specific answer when dealing with both a columnbar and lineseries in the same chart.

can someone please help!

推荐答案

问题是当我将数据绑定到图表时,网格折叠了,图表也进入了.

我仍然希望隐藏该特定图形,直到我选择它来更改不透明度为止,现在该行已按原样呈现.
The problem was that i had the grid collapsed that i had my chart in when i was binding the data to the graph.

I still want that specific graph hidden until i select it change the opacity instead, now the line is rendered as it should.


这篇关于列栏+线系列,图表中的排序问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆