Dumbbell chart — pure SVG, zero JS.
Shows before/after comparison with two dots connected by a bar. Horizontal orientation: categories on Y-axis, values on X-axis.
Examples
<.dumbbell_chart data={[
%{label: "2023", start_value: 65, end_value: 85},
%{label: "2024", start_value: 70, end_value: 92}
]} />
Summary
Functions
Attributes
data(:list) - Data:[%{label, start_value, end_value}]. Defaults to[].start_color(:string) - Fill color for start dots. Defaults to"oklch(0.65 0.20 300)".end_color(:string) - Fill color for end dots. Defaults to"oklch(0.60 0.20 240)".bar_color(:string) - Stroke color for connecting bar. Defaults to"oklch(0.75 0.05 0)".dot_radius(:integer) - Radius of dot endpoints in pixels. Defaults to5.show_grid(:boolean) - Show X-axis grid lines. Defaults totrue.show_labels(:boolean) - Show axis tick labels. Defaults totrue.animate(:boolean) - Enable entrance animations. Defaults totrue.animation_duration(:integer) - Animation duration in ms. Defaults to600.theme(:map) - Chart theme overrides (see ChartTheme). Defaults to%{}.id(:string) - Unique ID for the chart (auto-generated if not provided). Defaults tonil.title(:string) - Chart title rendered above the visualization. Defaults tonil.description(:string) - Chart description for context (rendered below title). Defaults tonil.class(:string) - Defaults tonil.- Global attributes are accepted.