Skip to main content

Microsoft Silverlight

Answered Question Chart columnserie problemRSS Feed

(0)

WtFudgE
WtFudgE

Member

Member

3 points

21 Posts

Chart columnserie problem

  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
David Anson

Participant

Participant

1718 points

212 Posts

Microsoft
Answered Question

Re: Chart columnserie problem

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


http://blogs.msdn.com/delay

This posting is provided "AS IS" with no warranties, and confers no rights.
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities