points = {
const points = d3.sort(cars, d => d.Price).flatMap(({ name, ...values }, i) =>
Object.entries(values).map(([key, raw]) => ({
name,
country: name.split(" ")[0],
year: name.split(" ")[1],
key,
raw,
fx: (1 + i%7) % 4,
fy: Math.floor((1 + i%7) / 4)
}))
);
for (const [, g] of d3.group(points, d => d.key)) {
const m = d3.max(g, d => d.raw);
for (const d of g) d.value = d.raw / m;
}
return points;
}