{
const myDiv = html`<div/>`;
const filter_and_unpack = (key, year) =>
covidDataFiltered.filter(row => row['date'] == selectedDate).map(row => row[key]);
const casesOrDeaths = filter_and_unpack(viewBy, selectedDate)
const covidScale = d3
.scaleSqrt()
.domain(d3.extent(casesOrDeaths))
.range([4, 10]);
const covidSize = casesOrDeaths.map(d => covidScale(d))
const locations = filter_and_unpack('iso_code', selectedDate);
const hoverText = casesOrDeaths;
const data = [
{
type: 'scattergeo',
z: casesOrDeaths,
locations: locations,
hoverinfo:'text',
text: hoverText,
locationmode: 'world',
marker: {
size: covidSize,
line: {
color: "lightgrey",
width: 1
}
}
}
];
var layout = {
title: viewBy + `<br>${selectedDate}`,
showlegend: false,
geo: {
scope: 'world',
showland: true,
landcolor: 'rgb(217, 217, 217)',
showlakes: true,
lakecolor: 'rgb(128, 128, 255)'
}
};
Plotly.newPlot(myDiv, data, { ...layout, ...mapLayout }, { showLink: false });
return myDiv;
}