activeInflows = (transitions, title) => {
const getColor = label => colorMap[label]
const container = html`<canvas></canvas>`;
const flows = [
'First Time',
'Low-Value', 'New Low-Value', 'Reactivated Low-Value', 'High to Low-Value',
'High-Value', 'New High-Value', 'Low to High-Value', 'Reactivated High-Value'
]
new Chart(container, {
type: 'bar',
options: {
legend: { align: 'center', position: 'top' },
title: { display: true, text: title },
scales: {
xAxes: [{stacked: true}],
yAxes: [{stacked: true}]
}
},
data: {
labels: transitions.map((t) => dateDiffToHuman(t.date)),
datasets: flows.map((label, index) => ({
label,
data: transitions.map(s => s.transitions[label]),
backgroundColor: getColor(label)
}))
}
});
return container;
}