ShellUI Logo
ShellUI

Bar Chart

Vertical bar charts for comparing values across categories

The BarChart component renders vertical bar charts ideal for comparing discrete values across categories. Built on ApexCharts.Blazor with full ShellUI theme integration.

Installation

shellui add chart bar-chart
dotnet add package Blazor-ApexCharts

chart and chart-variants are auto-installed as dependencies.

Basic Usage

<BarChart TItem="SalesData"
    Data="@salesData"
    Title="Monthly Revenue"
    Name="Revenue"
    XValue="@(e => e.Month)"
    YValue="@(e => (decimal?)e.Revenue)"
    Theme="ChartTheme.Default"
    Height="350px" />

@code {
    private List<SalesData> salesData = new()
    {
        new("Jan", 12000), new("Feb", 19000),
        new("Mar", 15000), new("Apr", 25000),
        new("May", 22000), new("Jun", 30000)
    };

    record SalesData(string Month, decimal Revenue);
}

With Colorful Theme

<BarChart TItem="DepartmentBudget"
    Data="@budgetData"
    Title="Department Budgets"
    Name="Budget (USD)"
    XValue="@(e => e.Department)"
    YValue="@(e => (decimal?)e.Amount)"
    Theme="ChartTheme.Colorful"
    Height="400px" />

@code {
    private List<DepartmentBudget> budgetData = new()
    {
        new("Engineering", 250000),
        new("Marketing", 120000),
        new("Sales", 180000),
        new("Support", 95000),
        new("Design", 110000)
    };

    record DepartmentBudget(string Department, decimal Amount);
}

Monochrome Theme

<BarChart TItem="QuarterlyData"
    Data="@quarterlyData"
    Title="Quarterly Performance"
    Name="Revenue"
    XValue="@(e => e.Quarter)"
    YValue="@(e => (decimal?)e.Revenue)"
    Theme="ChartTheme.Monochrome"
    Height="350px" />

@code {
    private List<QuarterlyData> quarterlyData = new()
    {
        new("Q1 2024", 45000), new("Q2 2024", 52000),
        new("Q3 2024", 48000), new("Q4 2024", 61000)
    };

    record QuarterlyData(string Quarter, decimal Revenue);
}

With Subtitle

<BarChart TItem="SalesData"
    Data="@salesData"
    Title="Monthly Revenue"
    Subtitle="FY 2024 - All Regions"
    Name="Revenue"
    XValue="@(e => e.Month)"
    YValue="@(e => (decimal?)e.Revenue)"
    Theme="ChartTheme.Default"
    Height="350px" />

Custom Sizing

<BarChart TItem="SalesData"
    Data="@salesData"
    Title="Compact Chart"
    Name="Revenue"
    XValue="@(e => e.Month)"
    YValue="@(e => (decimal?)e.Revenue)"
    Theme="ChartTheme.Default"
    Height="250px"
    Width="500px" />

API Reference

PropertyTypeDefaultDescription
TItemGeneric typeThe data item type
DataIEnumerable<TItem>?nullData collection to visualize
Namestring"Data"Series name shown in tooltip
XValueFunc<TItem, object>?nullFunction to extract X-axis category
YValueFunc<TItem, decimal?>?nullFunction to extract numeric value
ThemeChartThemeDefaultColor theme (Default, Colorful, Monochrome)
Titlestring?nullChart title
Subtitlestring?nullChart subtitle
Heightstring?"400px"Chart height
Widthstring?"100%"Chart width
Classstring?nullAdditional CSS classes

On this page