Single / multi-series line chart — pure SVG, zero JS.
Lines animate in with a stroke-dashoffset draw effect. Optional dots
appear with a staggered pop-in. Uses polyline_length/1 computed
server-side for precise dasharray values.
Supports six curve interpolation modes via the :curve attribute:
:linear (default, straight segments), :smooth (Catmull-Rom splines),
:monotone (monotone cubic — prevents overshoot), :step_before,
:step_after, and :step_middle (stepped lines).
Examples
<.line_chart data={[
%{label: "Jan", value: 120},
%{label: "Feb", value: 200},
%{label: "Mar", value: 160}
]} />
<.line_chart
series={[
%{name: "2023", data: [%{label: "Q1", value: 100}, %{label: "Q2", value: 200}]},
%{name: "2024", data: [%{label: "Q1", value: 140}, %{label: "Q2", value: 280}]}
]}
show_dots={true}
colors={["oklch(0.60 0.20 240)", "oklch(0.65 0.22 30)"]}
/>
<.line_chart
data={[
%{label: "Jan", value: 120},
%{label: "Feb", value: 200},
%{label: "Mar", value: 160}
]}
curve={:smooth}
/>
Summary
Functions
Attributes
data(:list) - Single-series:[%{label, value}]. Defaults to[].series(:list) - Multi-series:[%{name, data: [%{label, value}]}]. Defaults to[].colors(:list) - Override default palette. Defaults to[].show_dots(:boolean) - Render data point circles. Defaults tofalse.show_grid(:boolean) - Render horizontal grid lines. Defaults totrue.show_labels(:boolean) - Render axis labels. Defaults totrue.stroke_width(:integer) - Line stroke width in px. Defaults to2.animate(:boolean) - Enable entrance animations. Defaults totrue.animation_duration(:integer) - Animation duration in ms. Defaults to800.curve(:atom) - Interpolation mode for the line.:lineardraws straight segments (polyline),:smoothuses Catmull-Rom splines,:monotoneuses monotone cubic interpolation, and:step_*variants draw stepped lines. Defaults to:linear. Must be one of:linear,:smooth,:monotone,:step_before,:step_after, or:step_middle.theme(:map) - Chart theme overrides (see ChartTheme). Defaults to%{}.show_point_labels(:boolean) - Show value labels above data points. Defaults tofalse.dot_symbol(:atom) - Symbol shape for data point dots (Recharts symbol pattern). Defaults to:circle. Must be one of:circle,:cross,:diamond,:square,:star,:triangle, or:wye.active_dot(:map) - Active dot config on hover:%{r: 8, color: "red"}. nil disables. Defaults tonil.segments(:list) - Per-segment styling:[%{start: idx, end: idx, color: string, dash: string | nil}]. Overrides default line rendering. Defaults to[].gap_strategy(:atom) - How to handle nil values in data::skipremoves,:zeroreplaces with 0,:interpolatefills linearly,:spanconnects across. Defaults tonil. Must be one ofnil,:skip,:zero,:interpolate, or:span.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.