Skip to content

DashboardCharts

A chart of series by category (KlyDashboardChart: bars, lines, areas or a donut) and a list of horizontal bars (KlyDashboardBars) with a funnel variant. The chart is drawn by KlyChart of Klyroo.UI as SVG, without a charting library.

On this page

Examples

Chart with a comparison series

A series with IsComparison is drawn muted (dashed as a line) and is left out of the totals and of a donut. Totals Sum or Average adds a totals row. OnSelect receives a DashboardChartSelection (the category, the key of the series and the value) when the user picks a bar or a point: a click, or Enter or Space on the one the arrow keys are on.

Revenue by month

Click a bar

  • 2026
  • 2025
Bar chart
Category20262025
Jan31.2K28.9K
Feb34.8K30.1K
Mar33.1K31.8K
Apr39.4K33K
May42K36.2K
Jun48.5K40.1K
2026: 229K

Nothing selected yet.

Razor
<div class="flex w-full flex-col gap-3">
    <KlyDashboardGrid>
        <KlyDashboardChart Title="Revenue by month" Subtitle="Click a bar" Span="12" Categories="_months" Series="_series"
                           Format="DashboardFormatPreset.Compact" Totals="DashboardChartTotals.Sum" OnSelect="Pick" />
    </KlyDashboardGrid>
    <p class="m-0 text-sm text-(--klyroo-text-muted)">@(_picked ?? "Nothing selected yet.")</p>
</div>

@code {
    private static readonly IReadOnlyList<string> _months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"];

    // The comparison series is drawn muted and is left out of the totals.
    private static readonly IReadOnlyList<DashboardChartSeries> _series =
    [
        new("rev26", "2026", [31_200, 34_800, 33_100, 39_400, 42_000, 48_500]),
        new("rev25", "2025", [28_900, 30_100, 31_800, 33_000, 36_200, 40_100], IsComparison: true),
    ];

    private string? _picked;

    private void Pick(DashboardChartSelection point) =>
        _picked = $"{point.Category}, series {point.Series}: {point.Value:N0}";
}

Chart types

Type is Bar (the default), Line, Area or Donut. Stacked stacks the series of a bar or area chart, Horizontal draws the bars of a bar chart along the horizontal axis, and ShowLegend and Height change the legend and the drawing. A donut draws the first series that is not a comparison, one slice per category, with the total in the middle.

Line

  • Web
  • Mobile
Line chart
CategoryWebMobile
Jan12K8.1K
Feb13.4K9K
Mar14.1K9.8K
Apr15.8K11.2K
May16.9K12.7K
Jun18.3K14.5K

Stacked area

  • Web
  • Mobile
Area chart
CategoryWebMobile
Jan12K8.1K
Feb13.4K9K
Mar14.1K9.8K
Apr15.8K11.2K
May16.9K12.7K
Jun18.3K14.5K

Donut

The first series, one slice per category

54.6K Visits
  • Search21K
  • Direct14.3K
  • Social12.9K
  • Email6.4K
Donut chart
CategoryVisits
Search21K
Direct14.3K
Social12.9K
Email6.4K

Horizontal bars

Horizontal bar chart
CategoryVisits
Search21K
Direct14.3K
Social12.9K
Email6.4K
Razor
<KlyDashboardGrid>
    <KlyDashboardChart Title="Line" Span="6" Height="180" Type="DashboardChartType.Line" Categories="_months" Series="_traffic"
                       Format="DashboardFormatPreset.Compact" />
    <KlyDashboardChart Title="Stacked area" Span="6" Height="180" Type="DashboardChartType.Area" Stacked="true" Categories="_months" Series="_traffic"
                       Format="DashboardFormatPreset.Compact" />
    <KlyDashboardChart Title="Donut" Subtitle="The first series, one slice per category" Span="6" Height="180" Type="DashboardChartType.Donut"
                       Categories="_channels" Series="_shares" Format="DashboardFormatPreset.Compact" />
    <KlyDashboardChart Title="Horizontal bars" Span="6" Height="180" Horizontal="true" ShowLegend="false"
                       Categories="_channels" Series="_shares" Format="DashboardFormatPreset.Compact" />
</KlyDashboardGrid>

@code {
    private static readonly IReadOnlyList<string> _months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"];
    private static readonly IReadOnlyList<string> _channels = ["Search", "Direct", "Social", "Email"];

    private static readonly IReadOnlyList<DashboardChartSeries> _traffic =
    [
        new("web", "Web", [12_000, 13_400, 14_100, 15_800, 16_900, 18_300]),
        new("mobile", "Mobile", [8_100, 9_000, 9_800, 11_200, 12_700, 14_500]),
    ];

    private static readonly IReadOnlyList<DashboardChartSeries> _shares =
    [
        new("visits", "Visits", [21_000, 14_300, 12_900, 6_400]),
    ];
}

Bars, top N and funnel

A bar can carry a Tag, a Meta text that replaces its formatted value and Selected. With OnSelect every bar is a button (aria-pressed follows Selected), but the block does not keep the selection: the page rebuilds the items. Limit keeps the first bars, Emphasis First colors only the first, and the scale always includes zero. The funnel variant scales every bar to the first one and shows its share of the previous step.

Revenue by region

Pick a bar

Top 3

Emphasis on the first bar, Limit 3

EMEAeu 42.3K
Americasus 36.4K
APAC 19.6K, growing

Signup funnel

Visitors base 100%10,000
Signups 24% of the previous step2,400
Trials 38% of the previous step900
Paid 34% of the previous step310

Selected region: none

Razor
<div class="flex w-full flex-col gap-3">
    <KlyDashboardGrid>
        <KlyDashboardBars Title="Revenue by region" Subtitle="Pick a bar" Span="6" Items="Regions()" Format="DashboardFormatPreset.Compact" OnSelect="Pick" />
        <KlyDashboardBars Title="Top 3" Subtitle="Emphasis on the first bar, Limit 3" Span="6" Items="_regions" Limit="3"
                          Emphasis="DashboardBarsEmphasis.First" Format="DashboardFormatPreset.Compact" />
        <KlyDashboardBars Title="Signup funnel" Span="12" Items="_funnel" Variant="DashboardBarsVariant.Funnel" Format="DashboardFormatPreset.Integer" />
    </KlyDashboardGrid>
    <p class="m-0 text-sm text-(--klyroo-text-muted)">Selected region: @(_selected ?? "none")</p>
</div>

@code {
    private static readonly IReadOnlyList<DashboardBarItem> _regions =
    [
        new("EMEA", 42_300, Tag: "eu"), new("Americas", 36_400, Tag: "us"), new("APAC", 19_600, Meta: "19.6K, growing"), new("LATAM", 7_800),
    ];

    private static readonly IReadOnlyList<DashboardBarItem> _funnel =
    [
        new("Visitors", 10_000), new("Signups", 2_400), new("Trials", 900), new("Paid", 310),
    ];

    private string? _selected;

    // Selected only marks the row: the page owns the selection and rebuilds the items.
    private IReadOnlyList<DashboardBarItem> Regions() => [.. _regions.Select(r => r with { Selected = r.Label == _selected })];

    private void Pick(DashboardBarItem bar) => _selected = bar.Label;
}

API

KlyDashboardChart

A chart over categories without a charting dependency: grouped bars, lines, bars with line series over them, or a donut of the first series, with a legend and optional totals.

Parameters

Name Type Default Description
Card bool true Whether the block draws its own surface (border, background and shadow; only the background in a panels grid). Defaults to true .
Categories IReadOnlyList<string> The labels of the horizontal axis, one per category, or the slices of a donut.
Class string Classes added to the root element, merged last so they win over the theme.
Format DashboardFormatPreset DashboardFormatPreset.Number How the values of labels, tooltips, totals and the table view are formatted. Values: Number, Integer, Decimal, Compact, Percent, Ratio, Delta, Points, Signed.
Freshness bool? Shows an Updated footer built from Source.UpdatedAt . When null , the value of the enclosing KlyDashboardGrid.Freshness applies, or false outside a grid.
Height int 220 The height of the drawing in pixels at its natural width of 640. The drawing keeps its proportions and shrinks with the card, so it is shorter in a narrow one. Defaults to 220.
Horizontal bool false Draws the bars of a bar chart along the horizontal axis, with the categories on the vertical one.
Menu bool? Shows the View as table, Download CSV and Expand buttons in the header once the content is displayed. Download CSV saves the block's table as a CSV file named after the title. When null , the value of the enclosing KlyDashboardGrid.Menu applies, or false outside a grid.
Series IReadOnlyList<DashboardChartSeries> The data series, all drawn (a donut draws the first one that is not a comparison) and all in the table view. Each series takes the next chart color of Klyroo.UI ( --klyroo-chart-1 to --klyroo-chart-6 , then neutral); comparison series are muted.
ShowLabels bool false Shows the formatted value above each bar (below a negative one). Lines, areas and donuts show their values in tooltips. It switches the chart to the compact drawing described at Type .
ShowLegend bool true Shows the legend: the series, or the slices with their value for a donut. Defaults to true .
Source IDashboardSource The resource whose state drives the block: a skeleton while it loads, an error message with a retry button, then the content. The block does not read Data from it, so pass the data through the other parameters. Without a source the content renders immediately.
Span int 8 Width of the block in columns of the grid, clamped between 1 and the Columns of the enclosing KlyDashboardGrid (12 outside a grid). Defaults to 8.
Stacked bool false Stacks the series of a bar or area chart instead of drawing them side by side or over one another. Comparison series are stacked too, so leave them out of a stacked chart.
Subtitle string A secondary line under the title.
Title string The heading of the block.
Totals DashboardChartTotals DashboardChartTotals.None The totals row: Average shows the average of each series, Sum the sum. Comparison series are left out. None , the default, shows nothing. Values: None, Sum, Average.
Type DashboardChartType DashboardChartType.Bar The chart type: Bar (the default) draws one bar per series in each category, side by side; Line draws every series as a line; Area draws every series as a line with the area under it filled; Donut draws the first series that is not a comparison as a ring of slices, one per category, with the total in the middle. The drawing is KlyChart of Klyroo.UI: value and category axes, gridlines, a tooltip that follows the pointer and the arrow keys, a bar or a line that starts at zero (a zero value has no bar, a negative value goes below the axis), and a data table for screen readers. In a bar chart, a series whose Type is Line is drawn as a line over the bars, but KlyChart cannot mix the two, so such a chart (and a chart with ShowLabels ) uses a compact drawing of its own: bars and lines from a zero baseline, without axes or gridlines, and Stacked and Horizontal do not apply. The type also picks the loading skeleton. Values: Bar, Line, Area, Donut.

Events

Name Type Description
OnSelect EventCallback<DashboardChartSelection> Called with the category, the series key and the value when the user picks a data point. In the drawing of KlyChart (every chart except the compact one described at Type ) the bars, points and slices themselves are the choice: a click on one, or Enter or Space on the one the arrow keys are on, with a pointer cursor and the same keyboard hint as KlyChart.OnSelect . A pick is reported for the series it landed on, a comparison series included (its own key and value); from the keyboard, or for a series with no value in that category, it is the first series that is not a comparison and has a value, and a category with nothing to pick is ignored. The compact drawing, which KlyChart cannot draw (a bar chart with a line series, or with ShowLabels ), has no selectable marks, so it shows a group of buttons under the drawing instead, one per category and series (one per slice for a donut, comparison series left out), which works with the keyboard and with a screen reader too. Use it to drill down, for example by setting a filter of the DashboardController .

KlyDashboardBars

Horizontal bars for a ranking, or a funnel with the conversion rate between steps.

Parameters

Name Type Default Description
Card bool true Whether the block draws its own surface (border, background and shadow; only the background in a panels grid). Defaults to true .
Class string Classes added to the root element, merged last so they win over the theme.
Emphasis DashboardBarsEmphasis DashboardBarsEmphasis.All All (the default) colors every bar. First colors the first bar and mutes the others. Values: All, First.
Format DashboardFormatPreset DashboardFormatPreset.Number How the values are formatted, unless an item supplies its own Meta text. Values: Number, Integer, Decimal, Compact, Percent, Ratio, Delta, Points, Signed.
Freshness bool? Shows an Updated footer built from Source.UpdatedAt . When null , the value of the enclosing KlyDashboardGrid.Freshness applies, or false outside a grid.
Items IReadOnlyList<DashboardBarItem> The bars, in display order.
Limit int? The maximum number of bars shown. The table view and the CSV export hold the same bars.
Max Double? The value that fills a whole bar. Defaults to the largest item. Ignored by the funnel variant. The scale always includes zero: a zero value has no bar and a negative value extends to the left of a zero line.
Menu bool? Shows the View as table, Download CSV and Expand buttons in the header once the content is displayed. Download CSV saves the block's table as a CSV file named after the title. When null , the value of the enclosing KlyDashboardGrid.Menu applies, or false outside a grid.
Source IDashboardSource The resource whose state drives the block: a skeleton while it loads, an error message with a retry button, then the content. The block does not read Data from it, so pass the data through the other parameters. Without a source the content renders immediately.
Span int 6 Width of the block in columns of the grid, clamped between 1 and the Columns of the enclosing KlyDashboardGrid (12 outside a grid). Defaults to 6.
Subtitle string A secondary line under the title.
Title string The heading of the block.
Variant DashboardBarsVariant DashboardBarsVariant.Bars Bars (the default), or Funnel : every bar is scaled to the first one and shows its share of the previous step. Values: Bars, Funnel.

Events

Name Type Description
OnSelect EventCallback<DashboardBarItem> Called with the bar when the user picks it. Each bar is then a button, so the choice works with the keyboard and with a screen reader, and aria-pressed follows Selected . Use it to drill down, for example by setting a filter of the DashboardController .