using RadCartesianChart for stacked grouped bars

8 posts, 0 answers
  1. John
    John avatar
    1 posts
    Member since:
    Feb 2014

    Posted 04 Mar 2014 Link to this post

    I am using RadCartesianChart to display stacked grouped bar chart shown in the attachment. I searched forums to get an idea and also looked at the demo source code, but I am not able to get it to work. I am using MVVM. Please show me a sample project using MVVM that will be able to do this.

    Thanks,
    John
  2. john
    john avatar
    2 posts
    Member since:
    Mar 2014

    Posted 05 Mar 2014 Link to this post

    Attached the picture
  3. UI for WPF is Visual Studio 2017 Ready
  4. Martin
    Admin
    Martin avatar
    1099 posts

    Posted 07 Mar 2014 Link to this post

    Hi John,

    You can achieve your requirement by using the CombineMode Stack along with the StackGroupKey property. The StackGroupKey property sets the key that defines in which stack group a series will be included.

    For your convenience I attached a sample project which demonstrates creating of clustered and stacked BarSeries. Note that the series in the project are created dynamically with the RadCartesianChart.SeriesProvider. Another thing you can keep in mind is that when you use the SeriesDescriptor you need to define a style for the ChartSeries. In the sample project the StackGroupKey is set through an attached property to a property from the business object. This is needed because of the fact the StackGroupKey property was not designed as a dependency property.

    Regards,
    Martin
    Telerik

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

  5. john
    john avatar
    2 posts
    Member since:
    Mar 2014

    Posted 07 Mar 2014 in reply to Martin Link to this post

    Hi martin,

    Thanks for the reply. I don't see the sample project attachment. Please attach it.

    Thanks,
    John
  6. Martin
    Admin
    Martin avatar
    1099 posts

    Posted 11 Mar 2014 Link to this post

    Hello John,

    I apologize for the inconvenience caused. I reattached the project and now you should be able to see it.

    Regards,
    Martin
    Telerik

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

  7. Artem
    Artem avatar
    4 posts
    Member since:
    Aug 2014

    Posted 30 Sep Link to this post

    Hi,

    I'm trying to implement exactly same thing in silverlight (sigh!) and it works except palette part. Ideally I'd like to have a separate palette for each series group, but it would do if each series would use different colour (like in your example). In my case though the colour is applied on group basis, i.e. my left and right bars are in different colours but I don't see stacked items. Is there a way to achieve this? Tried to search but found nothing...

    Thank you,

    Artem

  8. Martin
    Admin
    Martin avatar
    1099 posts

    Posted 30 Sep Link to this post

    Hi Artem,

    The palette of the chart operates per series (or per data point for some series). Coloring per group is not supported out of the box. To achieve your requirement you can use the DefaultVisualStyle of the series. There are couple approaches that I can suggest you:
    • Define a color/brush property in the view model of the data points and bind it to the background of the default visual. Based on the group of the data point, set its color.
    • Bind the background of the default visual with an IValueConverter and based on a property (lets say the index in the group) from the view model set a different color. 
    Check the attached project.

    Regards,
    Martin
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  9. Artem
    Artem avatar
    4 posts
    Member since:
    Aug 2014

    Posted 03 Oct in reply to Martin Link to this post

    Hi Martin,

    That worked like a charm. Thanks a lot!

    Cheers,

    Artem

Back to Top
UI for WPF is Visual Studio 2017 Ready