DataPremium

Line Chart Drawing

A plain single-colour SVG curve: the stroke draws itself from left to right in two seconds when the block appears, then a light area settles underneath.

SVGPath

Updated

This effect is part of Effect.Labs — 846 vanilla effects, some free, some premium. Data has 28 effects, including 1 free. Explore the category →

3 usage examples

How the light rises on a sunrise alarm clock — choosing the programme — Line Chart Drawing example 1

① How the light rises on a sunrise alarm clock — choosing the programme

WhenIn the alarm settings, three programmes: Gentle, Classic, Quick. On each choice the card on the right draws the rise of the light between 6:00 and the 6:45 alarm: a long slope, a half-hour ramp, or a flat stroke that rears up at the end.
Why“A 15-minute rise” says little; the shape of the stroke says it all. And drawing from left to right follows the direction of time: you watch the light arrive the way it will in the morning.
SettingsOne panel per programme, only one shown (hidden on the others); ten values each, data-min="0", data-max="100", data-unit="%". --lcw-height: 170px, --lcw-max-width: none, transparent background, one colour per programme (#f2b84b, #f08a4b, #ee6a86). The “dark” and “full light” markers and the times are printed by the page. In the scene, a click outside the buttons moves to the next programme.
Tickets sold week after week, against the previous edition — dashboard of a street theatre festival — Line Chart Drawing example 2

② Tickets sold week after week, against the previous edition — dashboard of a street theatre festival

WhenOn the box-office dashboard, two curves start twelve weeks before opening night: the 2025 edition in grey, complete, and the 2026 edition in orange-red, stopping at today, a little above the other.
WhyThe team's question is simple: are we ahead of last year? Two flat-coloured strokes are told apart with no elaborate legend, and the gap between them is read at the exact spot where the red one stops.
SettingsTwo roots stacked in the same box (position: absolute), same data-min="0" and data-max="7500". 2025: twelve values, --lcw-color: #b5a99f, --lcw-area: transparent. 2026: eight values, --lcw-color: #e4572e, root narrowed to calc((100% - 16px) * 7 / 11 + 16px) so that its weeks land on the other's. Ticks and weeks printed by the page. In the scene, both strokes are replayed on the first pointer movement.
Which city does this temperature curve belong to? — game on the climate page of a science site for schoolchildren — Line Chart Drawing example 3

③ Which city does this temperature curve belong to? — game on the climate page of a science site for schoolchildren

WhenOne question, one curve: twelve months of average temperatures are drawn under the question, three cities are offered. Once the answer is given, the explanation shows; the next question arrives with a new curve, dipping in July.
WhyThe progressive drawing is part of the game: you see the very cold winter before the summer, and revise your guess along the way. With no dots or figures on the line, nothing gives the answer away.
SettingsOne root per question, twelve values, data-min="-15", data-max="30" (same scale from one question to the next), data-unit="°C", --lcw-height: 132px, --lcw-color: #0e8f8a. The 0 °C and 20 °C lines and the month initials are printed by the page. In the scene, the curve is replayed on the first pointer movement; a click outside the buttons gives the right answer, the next one moves to the other question.

How it works

The HTML holds nothing but an empty block, div.lcw-chart. The data sits on the root: data-values (comma-separated numbers), data-labels (one name per point) and data-title. From these the script builds an SVG drawing made of two paths: the line, in straight segments from one point to the next, and the surface it encloses down to the bottom of the block.

The drawing is computed at the block's real size, in pixels: the stroke is 3 px thick whatever the width, with no distortion. If the block changes size (phone rotated, column narrowing), the points are placed again at once.

The animation starts when 35% of the block is visible. The stroke is one dash as long as the whole curve, which the stylesheet slides over 2 s: it looks as if it were being drawn. Halfway through, the area starts to appear and stops at 30% opacity, fading towards the bottom.

The vertical scale fits the data, with a tenth of margin above and below. Set data-min and data-max to start from zero or to make two curves share one scale. The block shows no axis, no ticks, no dots: only the line and its area.

Accessibility

  • Description read aloud: the block is an image (role="img") whose name is built from your attributes: “Sign-ups per month. Jan 20, Feb 40, Mar 30…”. Numbers are written in the page language, with data-unit when present.
  • Long series: that description lists every point. Beyond fifteen values or so, also offer a one-sentence summary or a table next to it.
  • System setting that limits animations: the curve and its area are shown finished, with no progressive drawing.
  • No hover, no focus: no tooltip, no clickable point. A precise value has to be written in the page.
  • Thin stroke: 3 px wide. On a coloured background, check that --lcw-color stands out clearly.

Browser compatibility

Script-built SVG, stroke-dasharray and stroke-dashoffset animated in CSS, IntersectionObserver, ResizeObserver. In Chromium 149, Firefox 151 and WebKit 26.5, with the eight stock values over 560 px: a 592 dash, offset at 294 after 0.6 s and at 0 after 2.2 s, area at 0.30; at 390 px the path is recomputed (412 dash); two overlaid roots each get their own gradient identifier.

Chrome 64+✓ Full (measured)
Firefox 69+✓ Full (measured)
Safari 13.1+✓ Measured in WebKit, not in Safari itself
Edge 79+✓ Full (Chromium engine)
Safari iOS 13.4+✓ Not checked on an iPhone
Chrome Android 64+✓ Full (Chromium engine)

Without ResizeObserver (Chrome 51 to 63, Safari 12.1) the curve draws but no longer follows size changes. Without IntersectionObserver it draws on load. Without JavaScript the block stays empty.

The code

HTML structure to paste into your page (the CSS + JS come with your purchase):

index.html — structure
<div class="fx-0240-root" data-title="Sign-ups per month" data-labels="Jan,Feb,Mar,Apr,May,Jun,Jul,Aug" data-values="20,40,30,70,55,90,75,110">
  <div class="lcw-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 / propertyDefaultEffect
data-values (HTML, on the root) 20,40,30,70,55,90,75,110 The series, at least two numbers. With only one, nothing is drawn. An entry that is not a number is skipped (the following labels shift by one).
data-labels, data-title (HTML) eight months, “Sign-ups per month” Point names and title, used only for the description read by screen readers.
data-unit (HTML) absent Unit for that description: % gives a percentage, any other text is appended to the number.
data-min, data-max (HTML) absent Bounds of the vertical scale. Without them the curve uses the full height.
--lcw-color (CSS) #6366f1 Stroke colour.
--lcw-area (CSS) 50% indigo Tint of the area, dimmed further on display. transparent for a line alone.
--lcw-height, --lcw-max-width (CSS) 150px, 560px Height of the drawing and the width it will not exceed.
--lcw-bg, --lcw-min-height (CSS) #0a0a0f, 300px Background and minimum height of the block around the drawing.

FAQ

Not by much, and you should know it: the script is the same give or take twenty-five lines. Line Chart Draw adds a two-colour gradient stroke and a glowing dot that lights up on every vertex; its area is stronger. This one is the pared-down version: one colour, no dots. It suits a curve that must stay discreet, take the colour of a series or sit on top of another one. Take one or the other, not both.
Put two roots in the same box with position: absolute, give them the same data-min and data-max, a transparent background and a colour each. If one has fewer points, reduce its width in proportion so the points stay aligned (the formula is in the second example). Each root creates its own gradient: they do not interfere.
Not by itself: rewriting data-values redraws nothing at that moment. Values are read again when the block changes size or reappears. The simplest way: write the new values, hide the block (hidden), then show it again a moment later; the curve is then drawn afresh with the new figures.