function renderDayInTheLifeInfographic(eventList, options = {}) {
options = addDefaults(options, {
width: 900,
kicker: 'Day in the life of',
title: 'Add Name',
subTitle: 'Add Dates'
});
options = addDefaults(options, {
height: (options.width * 9) / 16
});
options = addDefaults(options, {
funcDrawInner: function(svg) {
const [cx, cy] = [options.width / 2, options.height / 2];
const r1 = Math.min(cx, cy) * 0.8;
const r2 = r1 * 0.9;
const r3 = r2 * 0.7;
eventList.forEach(function(event, i) {
const endTime = eventList[(i + 1) % eventList.length].startTime;
if (event.startTime > endTime) {
event.startTime -= 24;
}
const theta1 = (2 * Math.PI * event.startTime) / 24;
const theta2 = (2 * Math.PI * endTime) / 24;
drawDoughnutSlice(svg, [cx, cy], r3, r1, theta1, theta2, {
fill: EVENT_TYPE_TO_COLOR[event.eventType],
stroke: 'none'
});
const r4 = r1 * 1.05;
const thetaOriginal = (theta1 + theta2) / 2;
let textAnchor = thetaOriginal < Math.PI ? 'start' : 'end';
const theta = (3 * Math.PI) / 2 - thetaOriginal;
const [x, y] = [cx - r4 * Math.cos(theta), cy + r4 * Math.sin(theta)];
let labelExtended = `${formatDuration(event.startTime, endTime)} ${
event.label
}`;
drawText(svg, [x, y], labelExtended, {
fill: STROKE_COLOR,
textAnchor: textAnchor,
fontFamily: 'Gill Sans',
fontSize: DEFAULT_STYLE.fontSize / 2
});
});
drawCircle(svg, [cx, cy], r1, {
fill: 'None',
stroke: STROKE_COLOR,
strokeWidth: 2
});
drawCircle(svg, [cx, cy], r2, {
fill: 'None',
stroke: STROKE_COLOR,
strokeWidth: 2
});
drawCircle(svg, [cx, cy], r3, {
fill: 'None',
stroke: STROKE_COLOR,
strokeWidth: 2
});
const N_TICKS = 24;
range(0, N_TICKS).forEach(function(i) {
const theta = (2 * Math.PI * i) / N_TICKS;
const [x1, y1] = [cx - Math.cos(theta) * r1, cy + Math.sin(theta) * r1];
const [x2, y2] = [cx - Math.cos(theta) * r2, cy + Math.sin(theta) * r2];
const strokeWidth = i % 3 === 0 ? 3 : 1;
drawLine(svg, [x1, y1], [x2, y2], {
stroke: STROKE_COLOR,
strokeWidth
});
});
}
});
return renderInfographic(options);
}