Skip to main content
Home Forums Silverlight Programming Silverlight Controls and Silverlight Toolkit Chart columnserie problem
1 replies. Latest Post by David Anson on June 27, 2009.
(0)
WtFudgE
Member
3 points
21 Posts
06-25-2009 3:50 AM |
Hi, I made 2 columnseries which are added to a chart I make. However when I was testing with fictional values, it always created the 2 columnseries between eachother, meaning e.g. a blue bar, a red bar, a blue bar again, a red bar again, etc. However now that I use the values coming from my database it shows them behind eachother, meaning e.g. a blue bar, another blue bar, a red bar, another red bar. You get my drift right? The reason I want this it because the red bars are the totals of the blue bars. So I want to have a red bar, then 3 blue bars, then a red bar again, again a couple of blue bars, etc. My xaml chart looks like this: <chartingToolkit:Chart x:Name="monthChart" Width="400" Height="350" Title="Totaal aantal prestaties:"> <chartingToolkit:Chart.LegendStyle> <Style TargetType="Control"> <Setter Property="Width" Value="0"/> <Setter Property="Height" Value="0"/> </Style> </chartingToolkit:Chart.LegendStyle> <chartingToolkit:Chart.Series> <chartingToolkit:ColumnSeries AnimationSequence="LastToFirst" IndependentValueBinding="{Binding Name}" DependentValueBinding="{Binding Value}" IsSelectionEnabled="True" /> <chartingToolkit:ColumnSeries AnimationSequence="LastToFirst" IndependentValueBinding="{Binding Name}" DependentValueBinding="{Binding Value}" IsSelectionEnabled="True"> </chartingToolkit:ColumnSeries>/> </chartingToolkit:Chart.Series> </chartingToolkit:Chart>The code behind it looks like this: ColumnSeries cs1 = monthChart.Series[0] as ColumnSeries; ColumnSeries cs2 = monthChart.Series[1] as ColumnSeries; List<Helper.StatsChartValues> stats1 = new List<Helper.StatsChartValues>(); stats1.Add(new Helper.StatsChartValues { Name = "Aanvaard", Value=e.Result.NrAanvaard }); stats1.Add(new Helper.StatsChartValues { Name = "Niet Aanvaard", Value = e.Result.NrNAanvaard }); stats1.Add(new Helper.StatsChartValues { Name = "Errors", Value = e.Result.NrErrors }); stats1.Add(new Helper.StatsChartValues { Name = "Warnings", Value = e.Result.NrWarnings }); List<Helper.StatsChartValues> stats2 = new List<Helper.StatsChartValues>(); stats2.Add(new Helper.StatsChartValues { Name = "Totaal Prestaties", Value = e.Result.NrAanvaard + e.Result.NrNAanvaard }); stats2.Add(new Helper.StatsChartValues { Name = "Totaal Foutmeldingen", Value = e.Result.NrErrors + e.Result.NrWarnings }); cs1.ItemsSource = stats1; cs2.ItemsSource = stats2; e.Result is obviously data (coming from a webservice, all integers)StatsChartValues is a simple helperclass which holds a Name and a Value. Any ideas how I can get the bars correct? Also the Names below the X-axis get outside the chartbox, how can I solve this? Because this looks very ugly. Thanks a lot for replies friends!
David Anson
Participant
1718 points
212 Posts
06-27-2009 3:35 AM |
I discuss the two kinds of Column/BarSeries behavior (unique vs. staggered) in this post that should be helpful here:
http://blogs.msdn.com/delay/archive/2008/12/09/silverlight-charting-gets-a-host-of-improvements-silverlight-toolkit-december-08-release-now-available.aspx