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

How do you sort categories for mulitple series (clusted bar series)

5 Answers 330 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Mitchell
Top achievements
Rank 1
Mitchell asked on 13 Jun 2014, 03:34 AM
I am displaying 2 or more BarSeries on a categorical x axis.  If the first series has x values of "A", "D", and "G", and a second series has values of "B" and "C", the categories are displayed on the X axis, from left to right as A D G B C. I understand that the categories from the first axis are added first, then the categories from the second axis, etc.  I want the categories to be sorted alphabetically: A B C D G.

I have tried creating a dummy series that has all possible x (category) values (sorted) and added it first to the chart (the y values are all zero). That does sort the categories, but it is unsatisfactory because my bar series are clustered. This reserves a space in the cluster for the fake 0 valued data point. I have tried to remove my fake series after adding my other series, but that does not work (I assume because it's removed before rendering takes place). I have  also tried to set the visibility of the point to Collapsed for y values of zero, but that did not alter the clustering of the bars.

Any help is appreciated.

Thanks - Mitch

5 Answers, 1 is accepted

Sort by
0
Accepted
Peshito
Telerik team
answered on 17 Jun 2014, 08:12 AM
Hi Mitchell,

As you mentioned in your post, the categorical axis orders the items in the way they are passed to it. In order to sort them in a specific manner, you need to sort the data source first.

It is a bit more complicated in your scenario having two or more series. The approach you have tried with having another series just to be sure that all the categories are being displayed might work. You said that the bars are clustered. Have you tried setting the Combine modes of your series to Stack? This way the bars should look fine and well positioned. Default value of series' Combine mode is Cluster.

If this does not help, could you give us a bit more information about your scenario so we can think of a better solution.

Regards,
Peshito
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
Mitchell
Top achievements
Rank 1
answered on 18 Jun 2014, 11:52 PM
Adding zero value points to each series for x values that exist in the whole set of series is what I've done & seems to be a fairly reasonable approach. However, I would like to see the chart handle missing values itself so that empty space is not allocated in the chart for those zero value points on categorical axes.
0
Accepted
Peshito
Telerik team
answered on 20 Jun 2014, 07:38 AM
Hi Mitchell,

RadChartView handles empty values. For that purpose items should have values represented as null. You can take a look at our online sample demonstrating this behavior. It is a silverlight demo, but the approach for WPF is the same.

Regards,
Peshito
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
Nathan
Top achievements
Rank 1
answered on 26 Jul 2018, 01:45 PM
I am having this same issue with multiple series. I show, at a minimum, three series in a categorical chart with multiple point series.  To show the multiple series, I use a RadCartesianChart.SeriesProvider.  I want to have a global sort order, so have tried creating a series that is the union of all of the items in all the others series, but with their values set to null.  I have tried adding this series both as the first and the last series in the ItemsSource of the SeriesProvider, all to no avail.  If I just show the single series, it sorts correctly, but if I add more than one, the sort order is lost.  Any hints?
0
Martin Ivanov
Telerik team
answered on 31 Jul 2018, 07:07 AM
Hello Nathan,

Alternative approach would be that before passing all series data to the chart to populate each series with dummy data points. In this case each series will have all categories. However, if this doesn't help I could suggest you to open a new support ticket and attach an isolate version of your project there. This way someone can take a look at your case and think of a possible solution for you.

Regards,
Martin Ivanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
ChartView
Asked by
Mitchell
Top achievements
Rank 1
Answers by
Peshito
Telerik team
Mitchell
Top achievements
Rank 1
Nathan
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or