ShellUI Logo
ShellUI

Charts

Data visualization components built on ApexCharts.Blazor with theme-aware styling

ShellUI v0.2.0 introduces 7 chart components built on ApexCharts.Blazor, offering beautiful, responsive, and theme-aware data visualizations for your Blazor applications.

Overview

Chart components are built with:

  • ApexCharts.Blazor: Professional charting library with rich interactivity
  • Generic Type System: TItem type parameter for strongly-typed data binding
  • Theme-Aware Containers: Charts use your CSS variables (--border, --card, --radius, --shadow)
  • Three Built-in Themes: Default, Colorful, and Monochrome color palettes
  • Custom Tooltips: Compact, shadcn-inspired tooltips with dark mode support

Chart Components

Installation

# Via CLI - install all chart components
shellui add chart bar-chart line-chart area-chart pie-chart multi-series-chart

# Charts require ApexCharts.Blazor
dotnet add package Blazor-ApexCharts

Or via NuGet:

dotnet add package ShellUI.Components
dotnet add package Blazor-ApexCharts

Quick Example

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

@code {
    private List<SalesData> salesData = new()
    {
        new("Q1", 12000), new("Q2", 19000),
        new("Q3", 15000), new("Q4", 25000)
    };

    record SalesData(string Quarter, decimal Revenue);
}

Chart Themes

ShellUI provides three built-in color themes via the ChartTheme enum:

ThemeDescriptionColors
ChartTheme.DefaultProfessional palette for light/dark modesBlue, Red, Green, Yellow, Purple
ChartTheme.ColorfulVibrant multi-color palette for emphasisBlue, Red, Green, Yellow, Purple, Pink, Cyan
ChartTheme.MonochromeMinimal, understated aestheticVarious shades of slate gray
@* Switch themes easily *@
<BarChart TItem="SalesData"
    Theme="ChartTheme.Default" ... />

<BarChart TItem="SalesData"
    Theme="ChartTheme.Colorful" ... />

<BarChart TItem="SalesData"
    Theme="ChartTheme.Monochrome" ... />

Theme-Aware Styling

Chart containers automatically integrate with your ShellUI theme:

/* Charts use these CSS variables from your theme */
var(--border)          /* Container border */
var(--card)            /* Background color */
var(--card-foreground) /* Text color */
var(--radius)          /* Border radius */
var(--shadow)          /* Box shadow */

Charts render with transparent backgrounds, inheriting your card styling. The container class is:

border border-border bg-card text-card-foreground overflow-hidden
[border-radius:var(--radius)] [box-shadow:var(--shadow)]

Shared API Reference

Base Chart Properties

PropertyTypeDefaultDescription
ThemeChartThemeDefaultColor theme (Default, Colorful, Monochrome)
Titlestring?nullChart title
Subtitlestring?nullChart subtitle
Heightstring?"400px"Chart height
Widthstring?"100%"Chart width
Classstring?nullAdditional CSS classes
ChildContentRenderFragment?nullChild content (for Chart base)

Typed Chart Properties (BarChart, LineChart, AreaChart, PieChart)

PropertyTypeDefaultDescription
DataIEnumerable<TItem>?nullData collection to visualize
Namestring"Data"Series name shown in legend/tooltip
XValueFunc<TItem, object>?nullFunction to extract X-axis value
YValueFunc<TItem, decimal?>?nullFunction to extract Y-axis value

ChartTheme Enum

ValueDescription
ChartTheme.DefaultBlue, Red, Green, Yellow, Purple
ChartTheme.ColorfulBlue, Red, Green, Yellow, Purple, Pink, Cyan
ChartTheme.MonochromeSlate gray variations

SeriesType Enum

ValueDescription
SeriesType.LineLine chart series
SeriesType.BarBar chart series
SeriesType.AreaArea chart series
SeriesType.PiePie chart series

Built-in Features

All chart components include:

  • Toolbar: Download, zoom, pan, and reset controls
  • Smooth Curves: Curve.Smooth with rounded line caps
  • Custom Tooltips: Multi-series tooltips with color markers
  • Responsive Legend: Bottom-positioned with styled markers
  • Grid Lines: Dashed grid lines for readability
  • Category Axis: Proper string label display on X-axis

Accessibility

Chart components include:

  • ARIA Labels: Descriptive labels for screen readers
  • Keyboard Navigation: Full keyboard support for interactive elements
  • Color Contrast: Theme colors meet WCAG contrast guidelines
  • Chart Data Attributes: data-chart-theme attribute for styling hooks

Performance

  • Efficient Rendering: ApexCharts handles efficient DOM updates
  • Smart Data Binding: Generic type system with delegate-based value extraction
  • Lazy Options: Chart options are computed once and cached
  • Transparent Backgrounds: Charts blend seamlessly with card containers

On this page