Search⌘ K
AI Features

Smoothing out Graph Lines

Explore how to enhance line graphs in D3 by using various interpolation techniques that smooth lines between data points. Understand how each curve method affects the visual interpretation of data trends, enabling you to choose the best smoothing style for your dataset.

How lines are drawn

When we draw a line graph, we’re taking two (or more) sets of coordinates and connecting them with a line (or lines). I know that sounds simplistic, but bear with me. When we connect these points, we’re telling the viewer of the graph that in between the individual points, you expect the value to vary in keeping with the points that the line passes through. So in a way, we’re trying to interpret the change in values that are not shown.

Now, this is not strictly true for all graph types, but it does hold for a lot of line graphs.

So when connecting these known coordinates together, we want to make the best estimate of how the values would be represented. In this respect, sometimes a straight line between points is not the best representation.

For instance, earlier, when demonstrating the extent function for graphing, we showed a graph of the varying values with the y-axis showing a narrow range.

The ...