Slope chart — before/after comparison with diagonal lines — pure SVG, zero JS.
Useful for showing rank or value changes between two time periods. Lines animate in with a dashoffset draw effect.
Examples
<.slope_chart
data={[
%{label: "Product A", from: 80, to: 95},
%{label: "Product B", from: 60, to: 45},
%{label: "Product C", from: 75, to: 70}
]}
left_label="2023"
right_label="2024"
/>
Summary
Functions
Attributes
data(:list) (required) - List of%{label, from, to}.left_label(:string) - Defaults to"Before".right_label(:string) - Defaults to"After".colors(:list) - Override default palette. Defaults to[].animate(:boolean) - Defaults totrue.animation_duration(:integer) - Defaults to700.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.