Published
Edited
Mar 17, 2020
1 star
Insert cell
md`# Coronavirus deaths map
## As per number of cases
### As of 14/03/2020
Source: Johns Hopkins University`
Insert cell
chart = {
// create SVG element
var svg = d3.select(DOM.svg(width, height));

// construct the element
svg
.append('path')
.datum(countries)
.attr('d', pathGenerator)
.attr('class', 'country')
.attr('fill', 'gray')
.attr('opacity', 0.3)
.attr('stroke', 'black')
.attr('stroke-width', '0.5');

var circles = svg
.selectAll('path')
.data(LatLngs)
.enter()
.append('circle');

circles
.attr("cx", d => d[2][0])
.attr("cy", d => d[2][1])
.attr('r', d => Math.sqrt(d[3]))
.attr('class', 'circle')
.attr("fill", "#d60f23")
.attr('opacity', 0.4)
.on("mouseover", function(d) {
div
.transition()
.duration(200)
.style("opacity", .9);
div
.html(
"<b>COUNTRY: </b>" +
d[0] +
"<br/><b>REGION: </b>" +
d[1] +
"</br><b>CONFIRMED DEATHS: </b>" +
"1" +
"</br>AS OF 14/03/2020"
)
.style("left", d3.event.pageX + "px")
.style("top", d3.event.pageY - 28 + "px");
})
.on("mouseout", function(d) {
div
.transition()
.duration(500)
.style("opacity", 0);
});

// pass to Observable to draw this block
return svg.node();
}
Insert cell
Insert cell
import { callout } from "@d3/line-chart-with-tooltip"
Insert cell
html`<style>div.tooltip {position: absolute; text-align: left; width: 180px; height: 55px; padding: 15px;font: 14px calibri; background: #d60f23; color: white; border: 2px; border-radius: 8px; pointer-events: none;} </style>`
Insert cell
{
for (var i = 0; i <= factor; i++) {
var LatLngElement = [
datadeaths[i]['Country/Region'],
datadeaths[i]['Province/State'],
projection([parseFloat(dataraw[i].Long), parseFloat(dataraw[i].Lat)]),
datadeaths[i]['3/14/20']
];
LatLngs[i] = LatLngElement;
}
}
Insert cell
div = d3
.select("body")
.append("div")
.attr("class", "tooltip")
.style("opacity", 0)
Insert cell
Insert cell
factor = dataraw.length - 1
Insert cell
format = d => `${d}`
Insert cell
Insert cell
datadeaths = d3.csv(
"https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Deaths.csv"
)
Insert cell
topojson = require("topojson-client@3")
Insert cell
path = d3.geoPath().projection(projection)
Insert cell
pathGenerator = d3.geoPath().projection(projection)
Insert cell
height = 720
Insert cell
projection = d3
.geoMercator()
.scale(150)
.translate([width / 2, height / 1.5])
Insert cell
width = 980
Insert cell
d3 = require("d3@5")
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more