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

4 posts, 2 answers
  1. Mitchell
    Mitchell avatar
    45 posts
    Member since:
    Mar 2013

    Posted 12 Jun 2014 Link to this post

    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
  2. Answer
    Peshito
    Admin
    Peshito avatar
    496 posts

    Posted 17 Jun 2014 Link to this post

    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.
     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Mitchell
    Mitchell avatar
    45 posts
    Member since:
    Mar 2013

    Posted 18 Jun 2014 Link to this post

    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.
  5. Answer
    Peshito
    Admin
    Peshito avatar
    496 posts

    Posted 20 Jun 2014 Link to this post

    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.
     
Back to Top