chart = {
const svg = d3.create("svg").attr("viewBox", [0, 0, width, height]);
svg
.append('rect')
.attr('width', width)
.attr('height', height)
.attr('fill', 'black');
svg
.append('g')
.selectAll('path')
.data(aggDataGeoJSON.features)
.enter()
.append("path")
.attr("fill", 'none')
.attr("stroke", "red")
.attr("stroke-linejoin", "round")
.attr('class', d => d.properties.highway)
.attr('opacity', d => {
if (
d.properties.highway == 'motorway' ||
d.properties.highway == 'trunk'
) {
return 0.95;
} else if (d.properties.highway == 'primary') {
return 0.9;
} else if (d.properties.highway == 'secondary') {
return 0.8;
} else if (d.properties.highway == 'tertiary') {
return 0.7;
} else if (d.properties.highway == 'residential') {
return 0.6;
} else {
return 0.4;
}
})
.attr('stroke-width', d => {
if (
d.properties.highway == 'motorway' ||
d.properties.highway == 'trunk'
) {
return 3;
} else if (d.properties.highway == 'primary') {
return 1.5;
} else if (d.properties.highway == 'secondary') {
return 0.6;
} else if (d.properties.highway == 'tertiary') {
return 0.4;
} else if (d.properties.highway == 'residential') {
return 0.3;
} else {
return 0.2;
}
})
.attr("d", path);
return svg.node();
}