How to Create a Column Chart in Blazor Chart?
This article explains how to create a column chart in Blazor Chart Component.
Creating column chart in Blazor Chart
Blazor Chart has various chart types which includes Column Chart to render a column chart, set the series Type as Column.
The following code example illustrates this.
Index.razor
@using Syncfusion.Blazor.Charts
<SfChart Title="Sales History of Product X">
<ChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.Category"></ChartPrimaryXAxis>
<ChartSeriesCollection>
<ChartSeries DataSource="@SalesReports" XName="X" YName="YValue" Type="ChartSeriesType.Column"></ChartSeries>
</ChartSeriesCollection>
</SfChart>
@code {
public class ChartData
{
public string X { get; set; }
public double YValue { get; set; }
}
public List<ChartData> SalesReports = new List<ChartData>
{
new ChartData { X= "USA", YValue= 20 },
new ChartData { X= "GBR", YValue= 27 },
new ChartData { X= "CHN", YValue= 26 },
new ChartData { X= "UK", YValue= 40 },
new ChartData { X= "AUS", YValue= 26 },
new ChartData { X= "IND", YValue= 10 },
new ChartData { X= "DEN", YValue= 26 },
new ChartData { X= "MEX", YValue= 35 },
};
}
The following image screenshot illustrates the output of the above code snippet.
Output:
Conclusion
I hope you enjoyed learning how to create column chart in Blazor Chart Component.
You can refer to our Blazor Chart feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Blazor Chart example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries 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!