Code
D3.js
Select & Style
Select elements and apply styles with d3.select() and d3.selectAll().
Data Binding
Bind arrays to DOM elements using the enter / join / exit pattern.
Bar Chart
Vertical bar chart with scaleBand, scaleLinear, and axis helpers.
Scales
Linear, sqrt, log, and sequential colour scales compared visually.
Line Chart
Multi-series time-series line chart with area fill.
Scatter Plot
Scatter plot with colour and size encoding per group.
Pie / Donut Chart
Donut chart using d3.pie() and d3.arc() with percent labels.
Area Chart
Stacked area chart with d3.stack() and scaleTime.
Histogram
Frequency histogram with d3.bin() and a normal-curve overlay.
Transitions
Animated attribute changes with easing functions and callbacks.
Zoom & Pan
Scroll-to-zoom and drag-to-pan via d3.zoom().
Force Graph
Draggable force-directed network graph with forceSimulation.
Treemap
Hierarchical squarified treemap with d3.hierarchy() and d3.treemap().
Chord Diagram
Relationship matrix visualised as a chord diagram with d3.chord().
Brush
Focus+context: brush a time window in the overview to filter the detail view.
Generative Art
Animated flow-field generative art with sine-harmonic noise and sequential colour scales.
Line Chart
Intermediate Multi-series line chart using scaleTime, d3.line() path generator, area fill, and curveCatmullRom smoothing. d3-shape/line
const x = d3.scaleTime()
.domain(d3.extent(data, d => d.date))
.range([0, innerWidth]);
const y = d3.scaleLinear()
.domain([0, 90])
.range([innerHeight, 0]);
// Line generator
const line = d3.line()
.x(d => x(d.date))
.y(d => y(d.value))
.curve(d3.curveCatmullRom);
// Area fill under the line
const area = d3.area()
.x(d => x(d.date))
.y0(innerHeight)
.y1(d => y(d.value))
.curve(d3.curveCatmullRom);
g.append('path').datum(data)
.attr('fill', '#4f46e520')
.attr('d', area);
g.append('path').datum(data)
.attr('fill', 'none')
.attr('stroke', '#4f46e5')
.attr('stroke-width', 2.5)
.attr('d', line);Key APIs
d3.scaleTime()— maps Date objects to pixel positionsd3.line()— path generator for line chartsd3.area()— path generator with y0 baseline for area filld3.curveCatmullRom— smooth curve interpolationd3.extent(array, accessor)— [min, max] helperd3.timeParse(format)/d3.timeFormat(format)— date parsing & formatting