Skip to content

No.428 · Analytics

Slope Chart

How a ranking changed between two periods, one line per item from old rank to new; climbers and fallers take opposite colours, and lines swing when you switch measure.

The prompt

Copy this text

Automatic copying is unavailable. Copy the selected text using your device’s copy command.

Written for the variant you picked above: Light

Build a slope chart of rank changes between two periods in SVG with no chart library. Each item (eight destinations) is a line from its rank in the first period (left column) to its rank in the second (right), with dots at both ends and labels outside each end: name and value on the left, value, name and a ▲3 / ▼2 change on the right. Lines that climbed take one pole of a diverging pair (blue), those that fell the other (red), unchanged ones neutral grey — never status colours — with a small legend. The headline names the biggest climber ("Salalah climbs 4 places"). A Bookings / Revenue switch re-ranks both columns and every line swings to its new positions (700ms, cubic out, interpolating ranks). Hovering an item dims the others (each item's hit area spans its whole line). A Table button shows the values and rank changes. Selected variant — Light (light): Apply the light theme. Where the brief above gives no colour values for it, choose a restrained light palette with text at 4.5:1 contrast or better. Keep the geometry, states and motion described above unchanged. This selection takes precedence over references to other themes or options in the general brief. Implement this selected appearance; do not add a variant picker or alternative appearances unless requested. Implementation requirements: Use React and TypeScript. Keep the component self-contained, with uniquely scoped CSS and no animation libraries. Include required imports, styles and font setup in the result. Interaction: Switch the measure to re-rank; hover a line to isolate it; use Table for the numbers. Motion: Re-ranking tweens over 700ms (cubic out); highlight fades 200ms. Accessibility: The SVG has a summary label; climbers and fallers are marked with ▲/▼ and numbers as well as colour; the table view lists every value and change. Reduced motion jumps to new ranks. Responsive behavior: The SVG scales with its width; labels stay outside the line ends. Touch: Tap to highlight; the table view covers precise reading. Preserve keyboard access, visible focus and reduced-motion behavior. Keep fictional demo data and simulated service calls in a separate usage example; expose callbacks for real actions and recover from rejected requests. Keep usage-example links inside the demo: use local buttons or prevent navigation. Demonstration links must not navigate to Vitrine routes or open other pages; preserve real URL support in the reusable component itself. Verify the result at narrow and wide viewport sizes, with keyboard input and reduced motion enabled.

Notes

Interaction
Switch the measure to re-rank; hover a line to isolate it; use Table for the numbers.
Motion
Re-ranking tweens over 700ms (cubic out); highlight fades 200ms.
Accessibility
The SVG has a summary label; climbers and fallers are marked with ▲/▼ and numbers as well as colour; the table view lists every value and change. Reduced motion jumps to new ranks.
Responsive
The SVG scales with its width; labels stay outside the line ends.
On touch
Tap to highlight; the table view covers precise reading.