CreateChart = (province)=> {
const data = provincefilt.filter(function(d) {
return [province].includes(d.province);
});
const Div = DOM.element('div', {
});
const X = data.reduce(function(acc, it) {
if(it.date) acc.push(it.date);
return acc;
},[]);
const Y = data.reduce(function(acc, it) {
if(it.total||it.total=='') acc.push(it.total);
return acc;
},[]);
const DF = {
x: X,
y: Y,
mode: 'lines+markers',
type: 'scatter',
line: {shape: 'spline'},
};
const DG = [DF];
const layout = {
title: `Confirmed case in ${province}`,
showLegend: true,
width: 450
};
Plotly.newPlot(
Div,
DG,
layout,
{
displayModeBar: true,
displaylogo: false,
}
);
return Div;
}