Skip to content
daisyBlazor

DumbbellChart

Two values per category joined by a line, so the size and direction of each change reads at a glance: response time before and after a release, per region. D3 computes the shared scale and ticks; the chart draws the dots in theme colours.
Compare
Cover · <DumbbellChart>
Dumbbell chartEurope: Start 240, End 180; US East: Start 210, End 170; Asia: Start 310, End 330; LatAm: Start 380, End 290150200250300350400EuropeUS EastAsiaLatAmEurope: Start 240, End 180 240180US East: Start 210, End 170 210170Asia: Start 310, End 330 310330LatAm: Start 380, End 290 380290

Examples

Basic

Each DumbbellItem has a Start and an End; StartLabel and EndLabel name them in the legend, and the values sit outside each pair.

p95 response time by region, before and after release 4.2
p95 response time by region, before and after release 4.2Europe West: Before 4.2 240 ms, After 4.2 180 ms; US East: Before 4.2 210 ms, After 4.2 170 ms; US West: Before 4.2 260 ms, After 4.2 205 ms; Asia Pacific: Before 4.2 310 ms, After 4.2 330 ms; South America: Before 4.2 380 ms, After 4.2 290 ms150200250300350400Europe WestUS EastUS WestAsia PacificSouth AmericaEurope West: Before 4.2 240 ms, After 4.2 180 ms 240 ms180 msUS East: Before 4.2 210 ms, After 4.2 170 ms 210 ms170 msUS West: Before 4.2 260 ms, After 4.2 205 ms 260 ms205 msAsia Pacific: Before 4.2 310 ms, After 4.2 330 ms 310 ms330 msSouth America: Before 4.2 380 ms, After 4.2 290 ms 380 ms290 ms
Before 4.2 After 4.2
website/Examples/Charts/DumbbellChartBasicExample.razor Source

Colours

StartColor and EndColor take any CSS colour; ShowValues="false" leaves the numbers to the tooltips.

Active seats per workspace, Q1 and Q4
Active seats per workspace, Q1 and Q4Starter: Q1 3.1, Q4 3.8; Team: Q1 14.5, Q4 19.2; Business: Q1 42, Q4 57; Scale: Q1 61, Q4 66010203040506070StarterTeamBusinessScaleStarter: Q1 3.1, Q4 3.8 Team: Q1 14.5, Q4 19.2 Business: Q1 42, Q4 57 Scale: Q1 61, Q4 66
Q1 Q4
website/Examples/Charts/DumbbellChartColorsExample.razor Source

Playground

p95 response time by region, before and after release 4.2
p95 response time by region, before and after release 4.2Europe West: Before 4.2 240 ms, After 4.2 180 ms; US East: Before 4.2 210 ms, After 4.2 170 ms; US West: Before 4.2 260 ms, After 4.2 205 ms; Asia Pacific: Before 4.2 310 ms, After 4.2 330 ms; South America: Before 4.2 380 ms, After 4.2 290 ms150200250300350400Europe WestUS EastUS WestAsia PacificSouth AmericaEurope West: Before 4.2 240 ms, After 4.2 180 ms 240 ms180 msUS East: Before 4.2 210 ms, After 4.2 170 ms 210 ms170 msUS West: Before 4.2 260 ms, After 4.2 205 ms 260 ms205 msAsia Pacific: Before 4.2 310 ms, After 4.2 330 ms 310 ms330 msSouth America: Before 4.2 380 ms, After 4.2 290 ms 380 ms290 ms
Before 4.2 After 4.2
<DumbbellChart
               StartLabel="Before 4.2"
               EndLabel="After 4.2"
               ValueFormat="{0:N0} ms"
               Title="p95 response time by region, before and after release 4.2"
               Items="@_regions" />

@code {
    private readonly DumbbellItem[] _regions =
    [
        new("Europe West", 240, 180),
        new("US East", 210, 170),
        new("US West", 260, 205),
        new("Asia Pacific", 310, 330),
        new("South America", 380, 290),
    ];
}

API

<DumbbellChart>

DaisyBlazor.Charts

Parameters

  • AspectRatio double
    = 1.78

    Width divided by height. The chart keeps this shape at any width; its text keeps its size.

  • EndColor string
    = null

    Colour of the end dots (any CSS colour). Defaults to the theme's primary colour.

  • EndLabel string
    = "End"

    Name of the second value, shown in the legend and tooltips.

  • Items IReadOnlyList<DumbbellItem>
    = []

    The rows, one per category. Rows whose Start or End is not a finite number are skipped.

  • RowHeight double?
    = null

    Height of each row in px, for a chart that lays its categories out as rows (horizontal bars, a Gantt's lanes, a heatmap's rows…): its height then follows its number of rows instead of AspectRatio, so a long list keeps readable rows at any width. A chart, or an orientation, without rows ignores it.

  • ShowLegend bool
    = true

    Show the legend naming the two values.

  • ShowTitle bool
    = true

    Draw Title as a visible heading above the chart (the default); false keeps it only as the chart's accessible name, for a chart inside a card that already has a heading.

  • ShowValues bool
    = true

    Write each value beside its dot.

  • StartColor string
    = "color-mix(in oklab, var(--color-base-content) 40%, transparent)"

    Colour of the start dots (any CSS colour). Defaults to a muted text colour so the end stands out.

  • StartLabel string
    = "Start"

    Name of the first value, shown in the legend and tooltips.

  • Title string
    = null

    Optional heading rendered above the chart; it is also the chart's accessible name.

  • ValueFormat string
    = "{0:#,0.##}"

    Format string for values in labels and tooltips, e.g. "{0:N0} ms".

  • Width string
    = "100%"

    CSS width of the chart wrapper.

  • Class string
    = null

    Additional CSS classes merged onto the w-full wrapper.

  • Style string
    = null

    Inline styles appended after the width on the wrapper.

Something went wrong while running the docs. Reload