Skip to main content
100%

Line Interpolation

✓ Published0🌍 Public
Mmbostock
Last edited Feb 9, 2016
Created on Aug 10, 2012

This example demonstrates a custom line interpolation method in D3 v3 that connects data points with elliptical arcs instead of straight line segments. The visualization plots 20 generated data points on a scatterplot with axes, drawing a smooth arc between each consecutive point using SVG path commands. The custom interpolator is implemented by overriding d3.svg.line’s interpolate function to join coordinates with the "A 1,1 0 0 1" arc segment syntax, while the line’s x and y accessors map the data through linear scales. Circles mark each original data point, rendered with SVG.

AI-generated description

D3 2.10 allows you to implement custom interpolators for d3.svg.line and d3.svg.area. This contrived example shows how to draw arcs between data points using SVG’s elliptical arc path segments.

var line = d3.svg.line()
    .interpolate(function(points) { return points.join("A 1,1 0 0 1 "); })
    .x(function(d) { return x(d.x); })
    .y(function(d) { return y(d.y); });
gpl-3.0 Licensed

Similar vizzes