Charts
TwBarChart
TwBarChart is a Blazor bar chart that compares categories with horizontal bars. Supports grouped, stacked, 100% stacked and diverging layouts.
Last updated
Please be aware this component is new, may have bugs and/or be subject to change. Please report any bugs at
https://github.com/twblazor/twblazor/issues.
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.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.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.
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.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.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.
Summary
Tooltips and the table view give the value of every series for each category.