Slide 31
Slide 31 text
function AreaChart({ width, height, points }) {
let i = 0;
let path = Path().moveTo(0, h)
.lineTo(0, points[i].y)
.lineTo(points[i].x, points[i].y);
for (i = 1; i < 24 - 2; i++) {
const p = points[i];
const q = points[i + 1];
const xc = (p.x + q.x) / 2;
const yc = (p.y + q.y) / 2;
path = path.curveTo(p.x, p.y, xc, yc);
}
path = path
.curveTo(points[i].x,
points[i].y,
points[i + 1].x,
points[i + 1].y)
.lineTo(CHART_WIDTH, points[i + 1].y);
const d = path.lineTo(w, h).close();
return
;
}