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

Stacked/Clustered bar series -- any way to bind observable collection to each cluster (as opposed to each series)

3 Answers 87 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 1
Joe asked on 20 May 2014, 01:38 PM
I've seen the demos on stacked/clustered bar series.  For our business model, it makes more sense for the primary bound ObservableCollection to represent each "cluster" of data.  The nested ObservableCollection would then contain the data points for each bar in the cluster.  This is the opposite from the demos, where the primary ObservableCollection represents each series of a single bar color.

Is there any way to construct the chart in the reverse from the demos?  I hope my explanation is clear enough.

Thanks!

3 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 22 May 2014, 02:28 PM
Hi Joe,

Your scenario sounds like you have  few series (clusters) and the bars of each series is placed in a different category slot. Can you confirm this is your scenario? If so, I can suggest you to take a look at the Dynamic Number of Series help article. Basically you can have a collection with view models for your series (clusters) and each series will have a collection of data points. To ensure each cluster will be in different category slot (the length between two adjacent ticks on the axis) you can set the property which is bound to the CategoryBinding of the BarSeries. For example, all items in "cluster1" will have a single category, all items in "cluster2' will have another category, etc. 

As for the coloring of the bars, by default when you set a Palette for the chart, each series will be colored with a different brush. If you want to alter this behavior (each data point to be different color) you can set the PaletteMode property of the BarSeries to DataPoint. The default value is Series. For example, if the PaletteMode is set to Series and you have two series, all items in the first one will be one color and the items in the other one will be another color. Otherwise (PaletteMode set to DataPoint) each data point will be different color. Note that this property will be applied only if you set a Palette on the chart.

For your convenience I attached a sample project that demonstrates this approach.

Please let me know if I am missing something.

Regards,
Martin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Joe
Top achievements
Rank 1
answered on 23 May 2014, 12:47 PM
Martin, thank you for the sample project and the article link.  That's almost what I want to do, but is there any way to make it work with a model like this:

public class ClusterData
{
     public string Category { get; set; }
     public ObservableCollection<DataItem> DataItems { get; set; }
}

public class DataItem
{
     public string SubCategory { get; set; }
     public int Value { get; set; }
}

Where the Category defines the x-axis category groupings and the SubCategory defines the series for each individual bar.  Is this possible?

0
Martin Ivanov
Telerik team
answered on 27 May 2014, 06:25 AM
Hello Joe,

Note that the RadChartView doesn't support sub categories and the data cannot be passed straight forward in the described manner. Another thing you can keep in mind is that when you populate chart series with data object, the series will need two properties to visualize the data points. One for the vertical axis and another one for the horizontal (for example: Catergory, Value). In order to display your view models on the chart you can filter your data so that each item in the DataItems collection (from your ClusterViewModel) has the same category.

Regards,
Martin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
ChartView
Asked by
Joe
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Joe
Top achievements
Rank 1
Share this question
or