Stacked Bars with different ItemsSource

Charts for WPF Forum

Posted 2 months ago by Rudi Buss
Version: 22.1.5
Avatar

I have a class "Data" with the properties string Name and double Income 

I'd like to have two series of bars.

The X-Value should be the name and the Y-Value the Income

The two series should have different ItemsSources, so e.g. the first series should have only two bars with different income values and the second series should have three bars with different income values. 

This is what I want to achieve:

Stacked Bar Example

Could you provide an example?

[Modified 2 months ago]

Comments (6)

Posted 2 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Rudi,

Please have a look at the Charts / Chart Types / Stacked Bar sample in our samples project.  The "Normal stacking" example in there shows how two series of data can be grouped by year.  

I think that is similar to your scenario, except in yours, you would need five series and the X-grouping would be done by name instead of year.  Think of a series as each thing in a chart that has its own color and legend item.  Thus a series in your example would need to be each one of the 5 income data sets, even if each series has a single item in it.

The code for that "Normal stacking" example should help get you started.


Actipro Software Support

Posted 2 months ago by Rudi Buss
Avatar

Hi,

thanks for the help. I've used your tips and I can display two "stacked bars", but there are still some problems.

-> I can't change the XAxes name. It's only working when XAxes is an integer, but I want to display a name (...or group by the name, not by the index)

-> I can't customize the XAxes

Here's a example project:

https://drive.google.com/file/d/1oZQi_54pvLtvQPTfiST_fGDon9sxrwKi/

Posted 2 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Rudi,

Thank you for the sample project.  We are looking into the issue and can confirm that this scenario isn't working properly.  We'll post back here once we have an update.


Actipro Software Support

Posted 2 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Rudi,

We've made some updates to how XYGroupedAxis handles multiple series to be more like other axis types.  If you write our support email address and mention this thread, we can send you a preview build to test the updates so far.


Actipro Software Support

Posted 2 months ago by Rudi Buss
Avatar

Hi,

thanks for the solution/dll's. It's working :)

Only thing I noticed: When I use this:

pltActi.XAxes.Add(new XYGroupedAxis() { LabelAngle = -45 })

...and my XAxes is Index

XPath = "Index"

...then the Angle ist still 0. But that's not okay, since XPath = "Name" is working.

Thanks!

Posted 2 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Rudi,

I'm glad the update helped.  For the thing you noticed, I think you'd want to replace the XYGroupedAxis with XYDoubleAxis if you are using Index and then the LabelAngle applies.  Index may be forcing a Double-based axis in that scenario since it's a Double value.  But now that Name is working for grouping, you shouldn't run into this anyhow.


Actipro Software Support

The latest build of this product (v24.1.2) was released 5 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.