{
const plts = cities.map((city, cityIdx) => {
const data = rawData.filter((d) => d.cityCN === city),
color = colorScheme[cityIdx % 10];
const plt = Plot.plot({
width: width / 3,
height: width / 5,
x: { nice: true, domain: [2010, 2024] },
y: { nice: true },
color: {
nice: true,
legend: true,
scheme: "BuRd",
domain: [30, 40],
type: "linear"
},
grid: true,
marks: [
Plot.frame({ stroke: "#3333" }),
Plot.linearRegressionY(data, {
x: "year",
y: "high",
fill: color,
stroke: color,
opacity: 0.8
}),
Plot.dot(data, {
x: "year",
y: "high",
fill: "high",
stroke: "#3333",
tip: true
})
]
});
return htl.html`
<div>
<h2 style="color: ${color}">
${city}
</h2>
${plt}
</div>
`;
});
return htl.html`
<div style='display: flex; flex-flow: wrap'>
${plts}
</div>
`;
}