{
let div = DOM.element('div');
let states = Object.keys(excessStates).map(name => excessStates[name].code);
let trace = {
type: 'choropleth',
locationmode: 'USA-states',
locations: states,
z: states.map(s => {
let stname = statecode.filter(x => x.code == s)[0].state;
let stateData = excessStates[stname];
let allCause = stateData.all
.map(x => (x['All Cause'] || 0) - x['Average 2015-2019'])
.reduce((a, b) => a + b);
return allCause;
})
};
Plotly.plot(div, [trace], {
title: 'total additional mortality within time range',
geo: {
scope: 'usa',
showlakes: true,
lakecolor: 'rgb(255,255,255)'
}
});
return div;
}