map_spike = {
const svg = d3
.create("svg")
.attr("viewBox", [0, 0, w, h])
.attr("class", "italy");
svg.append("path")
.datum(statesOuter)
.attr("class", "outer")
.attr("d", path)
.attr("id", "usPath")
.attr("stroke", "grey")
.attr('stroke-width', '1px')
svg
.selectAll(".subunit")
.data(estado.features)
.enter()
.append("path")
.attr("stroke", "#BBB")
.attr("class", "county")
.style('stroke-width', d => {
let index = currentData.findIndex(dd => dd.z === d.properties.cod);
let value = currentData[index] ? currentData[index][confirmed_or_deaths] : 0;
return value > 0 ? "0px" : "0.25px";
})
.attr("fill", d => {
let index = currentData.findIndex(dd => dd.z == d.properties.cod);
let value = currentData[index] ? currentData[index][confirmed_or_deaths] : 0;
return value > 0 ? colorScaleFilled(value) : "#fff";
})
.attr("d", path)
.append("title")
.text(
d => {
let index = currentData.findIndex(dd => dd.z == d.properties.cod);
let value = currentData[index] ? currentData[index][confirmed_or_deaths] : 0;
return `${value}`;
}
)
;
svg
.selectAll("place")
.data(places.features)
.enter()
.append("circle")
.attr("r", 2.5)
.attr("fill","#fff")
.attr("stroke","#000")
.attr("transform", function(d) {
return "translate(" + projection(d.geometry.coordinates) + ")";
});
let label = svg
.selectAll(".place-label")
.data(places.features)
.enter()
.append("text")
.attr("class", "place-label2")
.style('paint-order', 'stroke')
.style('stroke-width', '3')
.style('stroke', 'rgba(255,255,255,.85)')
.style('stroke-linecap', 'round')
.style('stroke-linejoin', 'round')
.attr("transform", function(d) {
return "translate(" + projection(d.geometry.coordinates) + ")";
})
.attr("dy", ".35em")
.text(function(d) {
return d.properties.name;
})
.attr("pointer-events","none")
.attr("x", function(d) {
return d.geometry.coordinates[0] > -1 ? -6 : 6;
})
.style("text-anchor", function(d) {
return d.geometry.coordinates[0] < -1 ? "start" : "end";
});
label.append("tspan")
.attr("class", "additionalnum")
.style('font-weight', 'bold')
.attr("x", d => label.x)
.attr("y", d => label.y)
.text(d => {
let index = currentData.findIndex(dd => dd.z == d.properties.cod);
let value = currentData[index] ? currentData[index][confirmed_or_deaths] : 0;
return " (" + value + ")";
})
const wrapper = html`<div class="wrapper"></div>`;
wrapper.append(svg.node());
return wrapper;
}