function prepareForRank(mapTrips, years, portNames) {
const r = [];
const accCounts = {};
for (const y of years) {
for (const p of portNames) {
if (!accCounts[p]) accCounts[p] = 0;
let yCount;
if (!mapTrips.has(y)) yCount = 0;
else if (!mapTrips.get(y).has(p)) yCount = 0;
else yCount = mapTrips.get(y).get(p).length;
r.push({
date: new Date(y, 0),
name: p,
category: "dummy",
value: yCount + accCounts[p]
});
accCounts[p] += yCount;
}
}
return r;
}