plotGrowth = (type, h, reverse) => {
const dfi = df.
filter(aq.escape(d => d.type == type))
const dfisum = dfi.
groupby(['created_at', 'created_at_string', 'type']).
rollup({download_count: op.sum('download_count')})
const height = sizeScale(h * typeSize[type].pp)
const scaleOptions = {
grid: true,
tickSize: 0,
label: null
}
return addTooltips(Plot.plot({
width: width,
height: height,
marginRight: 0,
marginLeft: 0,
marginTop: 0,
marginBottom: 0,
style: {
color: frameColors.light,
background: frameColors.plotBackground,
},
color: {
legend: true
},
x: {
...scaleOptions,
ticks: 50,
tickFormat: d => '',
},
y: {
...scaleOptions,
ticks: 10 * typeSize[type].pp,
tickFormat: d => '',
domain: [0, typeSize[type].maxY],
reverse: reverse,
},
marks: [
Plot.areaY(dfi, Plot.stackY({
x: 'created_at',
y: 'download_count',
z: 'distribution',
fill: 'color',
fillOpacity: .85,
curve: 'basis',
stroke: frameColors.background,
strokeWidth: .9,
order: 'sum'
})),
Plot.dot(dfisum, {
x: 'created_at',
y: 'download_count',
title: d => `${d.download_count} downloads\n${d.created_at_string}`,
stroke: frameColors.light,
strokeWidth: .5,
r: 3,
fill: frameColors.plotBackground
}),
Plot.ruleX(yearMarks, {
stroke: frameColors.background,
strokeWidth: 5,
strokeOpacity: 1
})
]
}))
}