Bar Chart XYGroupedAxis: Inconsistent BarGroupSpacing behaviour

Charts for WPF Forum

Posted 6 years ago by Barry smith
Version: 18.1.0672
Platform: .NET 4.6
Environment: Windows 10 (64-bit)

I have a bar chart that sometimes displays a single data set, and sometimes displays two datasets. (The program displays calculated and measured levels, and uses the bar chart to allow quick visual comparison between the two. Sometimes the measured levels are unavailable.)

I would like to achieve the following behaviour:

When only one data set is available, it is shown with a space of 10 units between the bars.

When both data sets are available, they are shown with no spaces between the bars from different data sets, but space between each group.

Intuitively, I would like this to work by setting BarGroupSpacing to 10. However, when there is only one dataset, the bar chart doesn't seem to take notice of the BarGroupSpacing and instead uses BarSpacing.

I can work around this with a style, which sets the BarSpacing to 10 when only one dataset is available. I feel it would be neater if the library always used BarGroupSpacing.

 <Style TargetType="charts:XYGroupedAxis">
  <Setter Property="BarSpacing" Value="0"/>
  <Setter Property="BarGroupSpacing" Value="10"/> 
   <DataTrigger Binding="{Binding MeasuredDataAvailable}" Value="False">
    <Setter Property="BarSpacing" Value="10"/>

Comments (1)

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

Hi Barry,

Thanks for the feedback.  I believe the original thought behind the design is that there are only bar "groups" when you have more than one series.  That's why the BarGroupSpacing is ignored for a single series.  I'm glad you found a workaround for this.

Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.