Skip to main content
100%

Fork of Directly Labelled lines

✓ Published0🌍 Public
MMark Lam
Last edited Jan 19, 2022
Created on Jan 19, 2022

This example demonstrates directly labeled line charts using D3 v7, displaying three data series (Apples, Blueberries, Carrots) over a three-month time span with a shared y-axis scale from 0 to 20. The visualization uses a Voronoi diagram computed via `d3.Delaunay` to automatically position labels near each line’s end, selecting the largest cell polygon for optimal placement. Data is loaded from an external CSV file, parsed into date-value pairs, and rendered as SVG paths with `d3.line`. The coordinates and angles for label placement are calculated using the geometric library’s `polygonArea` and `polygonCentroid` functions.

AI-generated description

A demonstration of how to start using D3 version 6.

MIT Licensed

Similar vizzes