newUserOutflows = (data, title) => {
const getColor = label => colorMap[label]
const container = html`<canvas></canvas>`;
const flows = [
'Bounced',
'New Low-Value',
'New 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(d => dateDiffToHuman(d.date)),
datasets: flows.map((label, index) => ({
label,
data: data.map(s => s.transitions[label]),
fill: false,
borderColor:getColor(label),
backgroundColor: getColor(label)
}))
}
});
return container;
}