This is a migrated thread and some comments may be shown as answers.

How to set the series for the stacked bar chart

2 Answers 120 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Scott McEachern
Top achievements
Rank 1
Scott McEachern asked on 15 Jun 2010, 01:33 AM

Using the RadChart for Silverlight, version 2010.1.422.1040, I am having difficulty data binding using the “Stacked Bar Series”.  In the XAML, I have set the series and am attempting to set the item source within the code behind.

 

Here is the XAML:

<telerik:RadChart x:Name="chartMapDowRad" >

 

<telerik:RadChart.SeriesMappings>

                                                                                                                                                           

<telerikCharting:SeriesMapping LegendLabel="Summary">

                                                                                                                                                                       

<telerikCharting:SeriesMapping.SeriesDefinition>

<telerikCharting:StackedBarSeriesDefinition>

</telerikCharting:StackedBarSeriesDefinition>        

</telerikCharting:SeriesMapping.SeriesDefinition>

                                                                                                                                                                       

<telerikCharting:SeriesMapping.ItemMappings>

<telerikCharting:ItemMapping DataPointMember="XCategory" FieldName="Display" />

<telerikCharting:ItemMapping DataPointMember="YValue" FieldName="Value" />         

</telerikCharting:SeriesMapping.ItemMappings>


</telerikCharting:SeriesMapping>

                                                                                                                                               

</telerik:RadChart.SeriesMappings>

                                                                                                                                   

 </telerik:RadChart>

 

In the code behind, we have an object named “Results” that contains two observable collections, DayOfWeekSummaryFilter and “DayOfWeekSummary” which are to be be displayed within the chart.

 

this.chartMapDowRad.ItemsSource = result.DayOfWeekSummaryFilter;

 

I have only been able to set the ItemSource property on the RadChart for only one of the series.  In the Silverlight Toolkit, one was able to set the item source on each of the series.  Is this possible with the RadChart?

 

Thanks,

Scott

2 Answers, 1 is accepted

Sort by
0
Scott McEachern
Top achievements
Rank 1
answered on 16 Jun 2010, 12:22 AM
While waiting for a response I have been attempting to resolve the issue of displaying information with a stacked bar chart.  I have found that one can only set the itemSource on the chart and that you are unable to to bind the series sparately (which can be done with the Silverlight Toolkit).

To get multiple series to be displayed in the chart, these have to be within a collection and the XAML must set the index.  Below is the sample code:

<

 

 

telerikCharting:SeriesMapping LegendLabel="Summary" CollectionIndex="0" >

 

The problem that I have now encountered is that the chart is not updated when the source data is updated.  The series data is stored in a class that inherits from a list and implements the INotifyCollectionChanged.  The notify is called explicitly after all of the items in the list have been updated.  When there is only one series and this class is set as the ItemSource on the chart, the chart is updated correctly when the source data is updated.  However, for the stacked bar chart, there is the requirement to have two series and to get this to work, the class that implements the INotifyCollectionChanged must be placed in a list; with the additional class that is the other series.  The problem is that the chart is not updated.

I have attempted to place these classes (that implement the INotifyCollectionChanged) in both a list and observable collection with the same result; the chart is not updated.  Is it possible to use a stacked bar chart with data that changes?

Thanks,
Scott
0
Velin
Telerik team
answered on 17 Jun 2010, 04:07 PM
Hello Scott McEachern,

Binding the RadChart to an items source of this type should do the job:
RadHierarchicalObservableCollection<ObservableCollection<DataItem>>

Hope this will help.

All the best,
Velin
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Chart
Asked by
Scott McEachern
Top achievements
Rank 1
Answers by
Scott McEachern
Top achievements
Rank 1
Velin
Telerik team
Share this question
or