Dumbbell charts

A dumbbell chart compares two values per category: before and after, last year and this year, plan and actual. A hollow dot marks the first value, a filled dot the second, and the line between them shows how far and which way it moved.

Before and after

DumbbellSeries takes the category in XValue, the first value in FromValue and the second in YValue. With Horizontal the categories are rows, the usual layout; the value axis fits the values instead of starting at zero. DataLabels writes each value outside its dot. The tooltip shows "22 → 35 (+13)". Name the series after both ends, e.g. "2016 → 2026"; the legend shows a small dumbbell.

Chart "Trips by bike" with 1 series. 2016 → 2026: 6 values: Utrecht 33% to 41%, Malmö 30% to 33%, Freiburg 27% to 29%, Ghent 22% to 35%, Bologna 9% to 18%, Lyon 6% to 12%. Trips by bike51015202530354045UtrechtMalmöFreiburgGhentBolognaLyon33%41%30%33%27%29%22%35%9%18%12%Use Left and Right to move between points. Press Escape to leave.
Code
Razor
<RioChart TItem="City" Items="cities" Title="Trips by bike" Horizontal="true">
    <DumbbellSeries Name="2016 → 2026" XValue="c => c.Name" FromValue="c => c.Then" YValue="c => c.Now"
                    Format="0'%'" DataLabels="true" />
</RioChart>

@code {
    record City(string Name, double Then, double Now);
}

Plan against actual

Upright, with the categories along the bottom, a dumbbell reads as a gap from a plan. ColorValue colors the second dot, here red where the month fell short. With Aggregate, items in the same category make one dumbbell; both ends are combined the same way.

Chart "Hours" with 1 series. Plan → actual: 6 values: Jan 160 h to 152 h, Feb 150 h to 148 h, Mar 160 h to 171 h, Apr 160 h to 160 h, May 150 h to 139 h, Jun 150 h to 166 h. Hours120140160180JanFebMarAprMayJunUse Left and Right to move between points. Press Escape to leave.
Code
Razor
<RioChart TItem="Month" Items="months" Title="Hours">
    <DumbbellSeries Name="Plan → actual" XValue="m => m.Name" FromValue="m => m.Plan" YValue="m => m.Actual" Format="0 h"
                    ColorValue='m => m.Actual < m.Plan ? "--rio-negative" : null' />
</RioChart>

@code {
    record Month(string Name, double Plan, double Actual);
}

In JSON definitions

"type": "dumbbell" (also connectedDot, dotPlot) with x, a "from" field with the first values and y with the second. "horizontal": true on the chart makes rows.

{ "dataset": "trips", "horizontal": true, "series": [ { "type": "dumbbell", "x": "city", "from": "share2016", "y": "share2026" } ] }
An unhandled error has occurred. Reload 🗙