Published
Edited
Sep 22, 2018
5 forks
3 stars
Insert cell
Insert cell
Insert cell
Insert cell
picasso.chart({
element: document.querySelector('#container'),
data,
settings: {
collections: [{
key: 'stacked',
data: {
extract: {
field: 'Month',
props: {
series: { 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' } }, padding: 0.3 },
color: { data: { extract: { field: 'Year' } }, type: 'color' }
},
components: [{
type: 'axis',
dock: 'left',
scale: 'y'
},{
type: 'axis',
dock: 'bottom',
scale: 't'
}, {
type: 'legend-cat',
scale: 'color',
dock: 'top'
},{
key: 'bars',
type: 'box',
data: {
collection: 'stacked'
},
settings: {
major: { scale: 't' },
minor: { scale: 'y', ref: 'end' },
box: {
fill: { scale: 'color', ref: 'series' }
}
}
}]
}
})
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more