Line Chart Draw
SVG line chart that draws itself from left to right as it comes into view, with a tinted area fading in and a glowing dot lighting up on each point as the stroke passes.
Updated
This effect is part of Effect.Labs — 840 vanilla effects, some free, some premium. Data has 28 effects, including 1 free. Explore the category →
3 usage examples



How it works
Everything is set on the .fx-0226-root root: data-values (comma-separated numbers) and, optionally, data-labels, data-title, data-unit, data-min and data-max. The script builds an SVG inside .lcd-chart at the container's real size: an .lcd-area, an .lcd-line and one .lcd-dot per value. Both gradients get an id unique to each copy, so a chart hidden in a tab cannot wipe out another one's colours.
The vertical scale runs from the smallest to the largest value, widened by 10% on each side so the line does not touch the edges; data-min and data-max pin it. Points are evenly spaced across the full width with an 8 px margin. A ResizeObserver recomputes the path when the width changes, without replaying the animation.
When at least 35% of the chart is visible, the lcd-on class starts three animations, once: the stroke goes from a stroke-dashoffset equal to its length down to 0 in 2 s (ease-out), the area fades in over 1 s from 1 s, and each dot lights up in 0.5 s with a delay proportional to its position along the line. Dots therefore light up in order, right after the line passes, the last point included.
Accessibility
- Text alternative:
.lcd-charthasrole="img"and the script gives it anaria-labelbuilt from the data, e.g. “Site visits over six months. Jan 1,200, Feb 2,100…”. The SVG itself is hidden from screen readers. - Localised numbers: the values in that description are written with
Intl.NumberFormatin the page language, with thedata-unitunit. - Reduced motion: under
prefers-reduced-motion: reduce, the whole line, the area and every dot are shown at once. - No interaction: nothing focusable, nothing on hover or touch. To read an exact value on screen, add your own labels around the chart.
Browser compatibility
SVG built in JavaScript (IntersectionObserver, ResizeObserver, Intl.NumberFormat) and CSS animations on stroke-dashoffset and opacity. Measured on 8 Nov 2026 in Chromium 151, Firefox 153 and WebKit 26.5 (Playwright): two independent copies, the second only draws once shown, reduced motion, 390 px wide, no errors.
Without ResizeObserver, the line is computed at start-up and when it appears but no longer follows width changes. Without JavaScript the area stays empty: provide fallback text if the chart carries essential information.
The code
HTML structure to paste into your page (the CSS + JS come with your purchase):
<div class="fx-0226-root" data-title="Site visits over six months" data-labels="Jan,Feb,Mar,Apr,May,Jun" data-values="1200,2100,1650,3400,2800,3900">
<div class="lcd-chart" role="img"></div>
</div>
One-time payment, no subscription — the code is yours forever
Customize
Options passed to the API or data-* attributes:
| Option / property | Default | Effect |
|---|---|---|
Values (HTML — data-values on the root) |
1200,2100,1650,3400,2800,3900 | At least two comma-separated numbers, decimal point; a dot is drawn for each. |
Labels and title (HTML — data-labels, data-title) |
Six months, “Site visits over six months” | Only used for the description read by screen readers; nothing is written on screen. |
Unit (HTML — data-unit) |
None | Appended after each number in the description (% gives a localised percentage). |
Scale (HTML — data-min, data-max) |
Smallest and largest value, ±10% | Pin them to line the curve up with your own markers or to compare two charts. |
Colours (CSS — --lcd-from, --lcd-to, --lcd-area) |
#6366f1 → #d946ef, area rgba(99, 102, 241, .3) | Horizontal gradient of the stroke and tint of the area (which fades out downwards). |
Dots (CSS — --lcd-dot, --lcd-glow) |
#fff, glow rgba(99, 102, 241, .8) | Colour of the dots and of their glow. |
Size and background (CSS — --lcd-height, --lcd-max-width, --lcd-min-height, --lcd-bg) |
180 px, 560 px, 300 px, #0a0a0f | Chart height, maximum width, minimum root height, background (transparent on a light site). |
FAQ
.lcd-chart. Points are spread evenly with an 8 px margin, so a row of labels in justify-content: space-between lines up with them.