Error With Interpolate
I'm trying to smooth out the lines in a stacked area chart I have. But I'm getting an error. Here is a code snippet: const area = d3.area() .interpolate('cardinal') .x(
Solution 1:
Instead of:
const area = d3.area()
.interpolate('cardinal')
.x(d =>xScale(parseTime(d.data.date)))
.y0(d =>yScale(d[0] || 0))
.y1(d =>yScale(d[1] || 0));
It has to be:
const area = d3.area()
.curve(d3.curveCardinal)
.x(d =>xScale(parseTime(d.data.date)))
.y0(d =>yScale(d[0] || 0))
.y1(d =>yScale(d[1] || 0));
Here is the API regarding the curves: https://github.com/d3/d3-shape/blob/master/README.md#curves
Post a Comment for "Error With Interpolate"