function chart() {
const context = DOM.context2d(width, height),
path = d3.geoPath(projection).context(context);
context.beginPath();
path({ type: "Sphere" });
context.fillStyle = color(0);
context.fill();
context.lineWidth = 3;
context.stroke();
context.clip();
context.lineWidth = 0.5;
for (const c of contours) {
context.beginPath();
path(c);
context.strokeStyle = context.fillStyle = color(c.value);
context.fill();
context.stroke();
}
context.beginPath();
context.fillStyle = "lightblue";
for (const penta of polygons.features.slice(0, 12)) path(penta);
context.fill();
context.beginPath();
for (const hepta of polygons.features.filter(
d => d.geometry.coordinates[0].length == 8
)) {
path({ type: "Point", coordinates: d3.geoCentroid(hepta) });
}
context.fillStyle = "red";
context.fill();
context.beginPath();
context.fillStyle = "black";
for (const octo of polygons.features.filter(
d => d.geometry.coordinates[0].length == 9
))
path({ type: "Point", coordinates: d3.geoCentroid(octo) });
context.fill();
context.beginPath();
context.fillStyle = "lightblue";
for (const nona of polygons.features.filter(
d => d.geometry.coordinates[0].length == 10
))
path({ type: "Point", coordinates: d3.geoCentroid(nona) });
context.fill();
context.beginPath();
context.fillStyle = "darkorange";
for (const deca of polygons.features.filter(
d => d.geometry.coordinates[0].length == 11
))
path({ type: "Point", coordinates: d3.geoCentroid(deca) });
context.fill();
context.strokeStyle = "#fff";
context.beginPath();
path(polygons);
context.lineWidth = 0.5;
context.stroke();
context.strokeStyle = "black";
context.beginPath();
path(land);
context.lineWidth = 1.5;
context.stroke();
return context.canvas;
}