highOutflows = (data, title) => {
const getColor = label => colorMap[label]
const container = html`<canvas></canvas>`;
const states = ['High-Value', 'High to Low-Value', 'Lapsed High-Value']
const myChart = new Chart(container, {
type: 'bar',
options: {
title: { display: true, text: title },
legend: { align: 'start', position: 'right' },
scales: {
xAxes: [{stacked: true}],
yAxes: [{stacked: true}]
}
},
data: {
labels: data.map((t) => dateDiffToHuman(t.date)),
datasets: states.map((label, index) => ({
label,
fill: true,
backgroundColor: label.startsWith('Lapsed') ? color.red : label.includes('Low-Value') ? color.yellow : color.green,
data: data.map(s => s.transitions[label])
}))
},
});
return container;
}