Stacked Bar Chart where X axis labels/range is different between series

Charts for WPF Forum

Posted 8 years ago by Bill L
Version: 15.1.0623
Avatar

Hey,

Is it possible to create a stacked Bar chart with multiple series that may contain different groups of X axis labels or values?

Is there a way to establish the X axis range or string values that are common to all configured series data before adding the series data?

Currently, it appears that the first configured/added series establishes the X axis range of values.

I would prefer to use a stacked Bar chart vs. multiple Bar charts to visualize what is mostly common data.

 

Best regards,

Bill

Comments (6)

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Bill,

You should be able to do this if you explicitly define the axis in your XAML.  Then you have control over the major/minor ticks and how far apart they are.  For instance, this XAML seemed to work when I tried it on a couple series that had Tuple<int,int> data:

<charts:XYChart>
	<charts:XYChart.XAxes>
		<charts:XYDoubleAxis TickMajorInterval="5" TickMinorInterval="1" />
	</charts:XYChart.XAxes>
	<charts:XYChart.YAxes>
		<charts:XYDoubleAxis Minimum="0" Maximum="6" TickMajorInterval="2" TickMinorInterval="1" />
	</charts:XYChart.YAxes>
	<charts:BarSeries StackKind="Normal" ItemsSource="{Binding ElementName=window, Path=Data1}" XPath="Item1" YPath="Item2" />
	<charts:BarSeries StackKind="Normal" ItemsSource="{Binding ElementName=window, Path=Data2}" XPath="Item1" YPath="Item2" />
</charts:XYChart>


Actipro Software Support

Posted 8 years ago by Bill L
Avatar

Hey,

I don't think this will work for a grouped type axis, which is what I am using.  My X axis consists of string labels that are defined using a label function.  The Bar Series elements are created programmatically.

 <charts:XYChart.YAxes>
    <charts:XYDoubleAxis x:Name="YAxisNormal" LabelFormat="{}{1:0}" Style="{StaticResource AxisStyle}" Baseline="0" Minimum="0"/>
 </charts:XYChart.YAxes>

 <charts:XYChart.XAxes>
   <charts:XYGroupedAxis x:Name="XAxisGrouped" AreLabelsVisible="True" LabelAngle="-75"
                                LabelStyle="{StaticResource XAxisLabelStyle}" Style="{StaticResource XAxisStyle}"/>
 </charts:XYChart.XAxes>
Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Bill,

Have you checked into the XYGroupedAxis.GroupingFunc?  You can specify a function there that takes two data items and returns a boolean whether they are grouped.


Actipro Software Support

Posted 8 years ago by Bill L
Avatar

Hey,

I tried using the GroupedFunc property, but this does not resolve the issue. It appears that the first series data that is added establishes the full range of the X axis string labels using the LabelFunc property. If another series is added to the chart with an additional few X axis labels that are not present in the first added series data, then the missing or new data item labels are just automatically stacked onto the first bar in the chart as they don't have an existing X axis label or range item to plot against.

Is there a way to establish programmatically the range of data to use for the X axis (using GroupedAxis because of string label identifiers), prior to adding the series data or does it always require automatic calculation when the first series data is added?

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

I believe it's set from the data and can't be modified programmatically.  Could you possibly update the first series to be a union of all the group possibilities?  And for data points not in the first series that are in the second series, put a zero value in the first series for them.  That would likely establish all the groups you'd need then.


Actipro Software Support

Posted 8 years ago by Bill L
Avatar

Hey,   I used your suggestion on establishing a common set of series data and this works fine!

Thanks for the help.

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

Add Comment

Please log in to a validated account to post comments.