Charts
TwColumnChart
TwColumnChart is a Blazor column chart that compares categories with vertical columns. 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
TwColumnChart draws vertical columns whose length shows the value of each category. Columns suit short category labels and a handful of categories, and read naturally for values over time. Pass the category labels as Categories and one or more ChartSeries as Series. For the other direction use TwBarChart; 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">
<TwColumnChart 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">
<TwColumnChart 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">
<TwColumnChart 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">
<TwColumnChart 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.