Skip to main content
twblazor
Home
  • Get started
  • Tailwind with Blazor
  • Why twblazor?
  • Theme
  • Class Merge
    • Configuring localization
    • RTL Provider
  • Breadcrumb
  • Card
  • Carousel
  • Collapse
  • Context Menu
  • Drawer
  • Footer
  • Menu
  • Navbar
  • On This Page
  • Separator
  • Sidebar
  • Stepper
  • Tabs
  • Tree List
  • Container
  • Flex
  • Grid
  • Text
  • Link
  • Button
  • Form
    • AutocompleteNew
    • Checkbox
    • Color Picker
    • Date Picker
    • Date Range Picker
    • Datetime Picker
    • Datetime Range Picker
    • File Upload
    • Input GroupNew
    • NumericNew
    • Masked InputNew
    • Radio Button
    • Range SliderNew
    • RatingNew
    • Select
    • Slider
    • Switch
    • Tag InputNew
    • Text EditorNew
    • Textfield
    • Time Picker
    • Time Range Picker
  • Toggle
  • Toggle Group
  • Alert
  • Avatar
  • Badge
  • Chip
  • Empty
  • Icon
  • Popover
  • Progress
  • Skeleton
  • Spinner
  • Tooltip
  • Data Table
  • SpreadsheetNew
  • Column Filter Editor
  • Pagination
  • Pick List
  • Barcode
  • QR Code
  • Calendar
  • Table
  • Attachment
  • Overview
    • Bar
    • Bullet
    • Column
    • Dot Plot
    • Dumbbell
    • Icon
    • Lollipop
    • Radial Bar
    • Range
    • Word Cloud
    • Area
    • Bump
    • Bump Area
    • Candlestick
    • Gantt
    • Horizon
    • Line
    • Slope
    • Small Multiples
    • Stream Graph
    • Funnel
    • Gauge
    • Marimekko
    • Nightingale
    • Pie
    • Treemap
    • Waffle
    • Waterfall
    • Circular Treemap
    • Convex Treemap
    • Dendrogram
    • Sunburst
    • Barcode
    • Beeswarm
    • Box Plot
    • Density Plot
    • Histogram
    • Radial Histogram
    • Ridgeline
    • Strip Plot
    • Violin Plot
    • Categorical Scatter
    • Contour
    • Hexagonal Binning
    • Quadrant
    • Scatter
    • Heatmap
    • Matrix
    • Parallel Coordinates
    • Radar
    • Arc Diagram
    • Chord Diagram
    • Flowchart
    • Network Diagram
    • Sankey
    • Euler Diagram
    • Venn Diagram
  • Bubble
  • Marker
  • Message
  • Dialog Service
  • Toast Service
API DocumentationAI Agents & Skills
Home Get Started

Charts

TwBarChart

TwBarChart is a Blazor bar chart that compares categories with horizontal bars. Supports grouped, stacked, 100% stacked and diverging layouts.

Last updated 23 October 2026

Basic usage

TwBarChart draws horizontal bars whose length shows the value of each category. Bars suit long category labels and long lists, because the labels read left to right beside each bar. Pass the category labels as Categories and one or more ChartSeries as Series. For the other direction use TwColumnChart; the parameters are identical.
Revenue by regionThousands of pounds
NorthSouthEastWest
NorthSouthEastWest
NorthRevenue 420
SouthRevenue 310
EastRevenue 275
WestRevenue 380
0100200300400500
RAZOR
<TwChart Title="Revenue by region" Description="Thousands of pounds">
    <TwBarChart Categories="@_regions" Series="@_revenue" />
</TwChart>
CSHARP
@code {
    private readonly string[] _regions = ["North", "South", "East", "West"];
    
    private readonly ChartSeries[] _revenue = [new("Revenue", [420, 310, 275, 380])];
    
    private readonly ChartSeries[] _yearly =
    [
        new("2024", [360, 290, 240, 330]),
        new("2025", [420, 310, 275, 380])
    ];
}

Value labels

Set ShowValues to label each bar with its value. It works best with few bars; with many, the axis and tooltips carry the values more cleanly.
Revenue by region
NorthSouthEastWest
NorthSouthEastWest
420
310
275
380
NorthRevenue 420
SouthRevenue 310
EastRevenue 275
WestRevenue 380
0100200300400500
RAZOR
<TwChart Title="Revenue by region">
    <TwBarChart Categories="@_regions" Series="@_revenue" ShowValues="true" />
</TwChart>

Grouped

Pass more than one series and each category shows its series side by side. A legend appears automatically, and clicking an entry hides that series.
Revenue by region and year
NorthSouthEastWest
NorthSouthEastWest
North2024 3602025 420
South2024 2902025 310
East2024 2402025 275
West2024 3302025 380
0100200300400500
RAZOR
<TwChart Title="Revenue by region and year">
    <TwBarChart Categories="@_regions" Series="@_yearly" />
</TwChart>

Stacked

Set Stacking to ChartStacking.Stacked to pile the series on top of each other, so each bar shows the category total as well as its parts.
Revenue by region and year
NorthSouthEastWest
NorthSouthEastWest
North2024 3602025 420
South2024 2902025 310
East2024 2402025 275
West2024 3302025 380
0200400600800
RAZOR
<TwChart Title="Revenue by region and year">
    <TwBarChart Categories="@_regions" Series="@_yearly" Stacking="ChartStacking.Stacked" />
</TwChart>

100% stacked

ChartStacking.Percent scales every bar to the same length, so the chart compares shares instead of totals. Tooltips and the table view still show the original values.
Share of revenue by year
NorthSouthEastWest
NorthSouthEastWest
North2024 3602025 420
South2024 2902025 310
East2024 2402025 275
West2024 3302025 380
0%20%40%60%80%100%
RAZOR
<TwChart Title="Share of revenue by year">
    <TwBarChart Categories="@_regions" Series="@_yearly" Stacking="ChartStacking.Percent" />
</TwChart>

Diverging

Negative values grow the other way from the baseline. Stack a positive and a negative series to make a diverging chart, for example agreement against disagreement.
The new layout is easier to usePercent of responses
DesignEngineeringSalesSupport
DesignEngineeringSalesSupport
DesignAgree 62Disagree -18
EngineeringAgree 48Disagree -30
SalesAgree 35Disagree -41
SupportAgree 54Disagree -22
-50050100
RAZOR
<TwChart Title="The new layout is easier to use" Description="Percent of responses">
    <TwBarChart Categories="@_teams" Series="@_sentiment" Stacking="ChartStacking.Stacked" />
</TwChart>
CSHARP
@code {
    private readonly string[] _teams = ["Design", "Engineering", "Sales", "Support"];
    
    private readonly ChartSeries[] _sentiment =
    [
        new("Agree", [62, 48, 35, 54]),
        new("Disagree", [-18, -30, -41, -22])
    ];
}

Summary

Tooltips and the table view give the value of every series for each category.

Shared features

The legend, tooltips, keyboard navigation, table view, value formatting, height and empty state work the same on every chart. See TwChart for those options.

Keyboard navigation

The plot is a single Tab stop. Each data point is announced with its series and value as focus reaches it, and the table view presents the same data without the plot.
Key What it does
Tab Moves focus into the plot, onto the data point last visited.
Arrow Right or Arrow Down Moves to the next data point.
Arrow Left or Arrow Up Moves to the previous data point.
Home or End Moves to the first or last data point.
Escape Hides the tooltip of the focused data point.
Enter or Space On a legend item: shows or hides that series. On the table button: switches between the chart and its data table.

On this page

  • Basic usage
  • Value labels
  • Grouped
  • Stacked
  • 100% stacked
  • Diverging
  • Summary
  • Shared features
  • Keyboard navigation
twblazor

The Tailwind CSS component library for Blazor. Accessible, themeable and MIT licensed.

Discord (opens in a new tab) GitHub(opens in a new tab)

Get started

  • Install guide
  • Theming
  • Class merging
  • Localization

Guides

  • Tailwind CSS with Blazor
  • Why twblazor?
  • Right to left
  • AI agents and skills

Resources

  • API documentation (opens in a new tab)
  • llms.txt (opens in a new tab)
  • MIT License (opens in a new tab)

Community

  • Contributing (opens in a new tab)
  • Code of conduct (opens in a new tab)
  • Report an issue (opens in a new tab)

twblazor is and always will be free and open source.

An unhandled error has occurred. Reload