{
const data = todayData
const svg = d3.select(DOM.svg(width, height))
const radius = (height - margin.top - margin.bottom) / 2
const w = width - margin.left - margin.right
const h = height - margin.top - margin.bottom
let color = d3.scaleOrdinal(colors)
let pie = d3.pie()
.sort((a, b) => b.count - a.count)
.value(d => d.count)
.padAngle(0.01)
let path = d3.arc()
.outerRadius(radius)
.innerRadius(70)
let label = d3.arc()
.outerRadius(radius - 30)
.innerRadius(radius - 30)
let total = d3.sum(data, d => d.count)
function percent(val) {
return `${(100 * val / total).toFixed(2)}%`
}
let g = svg.append('g').attr('transform', `translate(${margin.left}, ${margin.top})`)
let pieGroup = g.append('g')
var arc = pieGroup.selectAll('.arc')
.data(pie(data))
.enter().append('g')
.attr('class', 'arc')
.attr('transform', `translate(${w/2}, ${radius + 10})`)
arc.append('path')
.attr('d', path)
.attr('fill', d => color(d.data.label))
return svg.node();
}