halfCircles = {
let rows = 8;
let columns = 7;
const height = width * (rows / columns);
const scale = 30;
const svg = d3.create("svg").attr("width", width).attr("height", height);
svg
.append("rect")
.attr("width", width)
.attr("height", height)
.attr("fill", "#f0f5f9");
for (let y = 0; y < rows; y++) {
for (let x = 0; x < columns; x++) {
let i = y * columns + x;
let state = transitComparisonData[i];
if (i > transitComparisonData.length - 1) {
break;
}
let ratio = state.otherTransit / state.driving;
let xCenter = (width / columns) * x + width / (columns * 2);
let yCenter = (height / rows) * y + height / (rows * 2);
svg
.append("path")
.attr(
"d",
"M " +
xCenter +
" " +
yCenter +
" a " +
scale +
" " +
scale +
" 0 0 0 " +
scale * 2 +
" 0"
)
.attr("transform", "translate(" + -scale + ",0)")
.attr("fill", "#6d819c");
svg
.append("path")
.attr(
"d",
"M " +
xCenter +
" " +
yCenter +
" a " +
scale * ratio +
" " +
scale * ratio +
" 0 0 1 " +
scale * ratio * 2 +
" 0"
)
.attr("transform", "translate(" + -scale * ratio + ",0)")
.attr("fill", "#75D701");
svg
.append("text")
.attr("x", xCenter)
.attr("y", yCenter + scale + 20)
.attr("font-size", 12)
.attr("text-anchor", "middle")
.attr("font-family", "Monaco")
.attr("fill", "#274c5e")
.text(stateLUT[state.name]);
}
}
return svg.node();
}