Click here to Skip to main content
15,906,645 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
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
CSS
<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" />


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!
Posted

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900