geom.line() layer over x and y position scales.
Basic example
scale.x() infers a datetime scale here, because Graphy recognizes the abbreviated month names (Jan, Feb, …) as dates. scale.y() infers a continuous scale from the numeric revenue. To treat the months as evenly spaced bands instead, use scale.x.discrete().
Multiple groups
Map a categorical column tocolor to split the data into one line per group, and add a color scale:
scale.color.discrete() draws group colors from Graphy’s default palette. To pin specific colors, use scale.color.discrete({ domain: ['North', 'South'], range: ['#4C6EF5', '#F76707'] }).
strokeWidth, lineType and alpha can be mapped too, each with its own scale: scale.strokeWidth.continuous(), scale.alpha.continuous(), and scale.lineType.discrete() for a dash pattern per group. lineType is discrete only. Mapping it to a numeric variable is an error, since there is nothing between two dash patterns to interpolate.
To single one layer out instead, give it an id and scope a style entry to it with { layer }:
Smoothing
Thecurve param sets how the path bends. 'linear', the default, draws straight segments; 'smooth' draws a curve through every point:
Area fill
A line draws no fill of its own. Declare afillAlpha style default to add a gradient beneath it, fading from the line’s color to transparent at the baseline:
geom.area() instead.
Missing values
Usenull for a missing cell. missingValues controls how the path treats the gap:
Points on the line
Add ageom.point() layer to mark every vertex. It shares the spec-level mapping, so both layers plot the same observations. Pipe it after the line so the dots sit on top, and set interactive: false on the point layer:
interactive: false keeps the points out of hit-testing, so the line owns hover: it picks the nearest point along the x-axis and drives the tooltip. Interactive points would fire hover only when the cursor lands on a dot.
Line params reference
'linear' | 'smooth'
default:"linear"
Curve family.
'smooth' smooths the line through every point.'gap' | 'connect' | 'zero'
default:"gap"
How the path handles
null values: break at the gap ('gap'), span it
('connect'), or treat as zero ('zero').style.geom.line({ stroke, fill, alpha, saturation, strokeWidth, dashArray, fillAlpha }). A line draws at strokeWidth: 2 and dashArray: [], with no fill until you declare a fillAlpha.
Related
- Styling — stroke width, dash, the fill wash and per-layer scoping
- Chart types overview — the full recipe list
- Axes — labels, ticks, grid and baseline
- Statistics — add a
smoothtrendline - Data structure — how columns feed the mapping

