How to Center Align Single Bars with Multiple Series in Blazor Charts?
This article explains how to center align bars without extra spacing when each series has only one data point.
Center aligning bars without spacing
Blazor Charts provides an option to center align column chart rectangles for single data point using the EnableSideBySidePlacement property.
When multiple series have a single data point with different x-values, each bar will be rendered with spacing for the x-values that aren’t available in each series. This occurs because column-type charts render data points side by side. To eliminate this spacing, set the EnableSideBySidePlacement property to false.
The code example below demonstrates how to center align bars without spacing:
@using Syncfusion.Blazor.Charts
<SfChart EnableSideBySidePlacement="false">
   <ChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.Category"></ChartPrimaryXAxis>
   <ChartSeriesCollection>
       <ChartSeries DataSource="@SalesDetails1" XName="X" YName="Y" Type="Syncfusion.Blazor.Charts.ChartSeriesType.Column">
       </ChartSeries>
       <ChartSeries DataSource="@SalesDetails2" XName="X" YName="Y" Type="Syncfusion.Blazor.Charts.ChartSeriesType.Column">
       </ChartSeries>
       <ChartSeries DataSource="@SalesDetails3" XName="X" YName="Y" Type="Syncfusion.Blazor.Charts.ChartSeriesType.Column">
       </ChartSeries>
   </ChartSeriesCollection>
</SfChart>
@code {
   public class ChartData
   {
       public string X { get; set; }
       public double Y { get; set; }
   }
   public List<ChartData> SalesDetails1 = new List<ChartData>
   {
       new ChartData { X= "Jan", Y= 35 },
   };
   public List<ChartData> SalesDetails2 = new List<ChartData>
   {
       new ChartData { X= "Feb", Y= 28 },
   };
   public List<ChartData> SalesDetails3 = new List<ChartData>
   {
       new ChartData { X= "Mar", Y= 34 },
   };
} 
The following screenshot illustrates the output of the code snippet:
Conclusion:
We hope you found this guide helpful in learning how to center align bars when using multiple series with single data points in Blazor Charts. For more features, visit our Blazor Charts feature tour page to learn about its other groundbreaking features, documentation, and how to quickly get started with configuration specifications. You can also explore our Blazor Charts example to understand how to create and manipulate data.
For current customers, our Blazor components are available on the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to evaluate our Blazor Charts and other Blazor components.
If you have any questions or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, support portal, or feedback portal. We are always happy to assist you!