picasso.chart({
element: document.querySelector('#container'),
data,
settings: {
collections: [
{
key: 'stacked',
data: {
extract: {
field: 'Month',
props: {
line: { field: 'Year' },
end: { field: 'Sales' }
}
},
stack: {
stackKey: d => d.value,
value: d => d.end.value
}
}
}
],
scales: {
y: {
data: {
collection: {
key: 'stacked'
}
},
invert: true,
expand: 0.2,
min: 0
},
t: { data: { extract: { field: 'Month' } } },
color: { data: { extract: { field: 'Year' } }, type: 'color' }
},
components: [
{
type: 'axis',
dock: 'left',
scale: 'y'
},
{
type: 'axis',
dock: 'bottom',
scale: 't'
},
{
key: 'lines',
type: 'line',
data: {
collection: 'stacked'
},
settings: {
coordinates: {
major: { scale: 't' },
minor0: { scale: 'y', ref: 'start' },
minor: { scale: 'y', ref: 'end' },
layerId: { ref: 'line' }
},
layers: {
curve: 'monotone',
line: {
show: true
},
area: {
fill: { scale: 'color', ref: 'line' }
}
}
}
}
]
}
})