-
element: document.querySelector('#container'),
data,
settings: {
collections: [
{
key: 'stacked',
data: {
extract: {
field: 'Date',
props: {
line: { field: 'Band' },
end: { field: 'Percent' }
}
},
stack: {
stackKey: d => d.value,
value: d => d.end.value
}
}
}
],
scales: {
y: {
data: {
collection: {
key: 'stacked'
}
},
invert: true,
expand: 0.2,
min: 0,
max: 100
},
t: { data: { extract: { field: 'Date' } } },
color: {
data: { extract: { field: 'Band' } },
type: 'categorical-color',
range: ['#E74C3C', '#F5B041', '#ABEBC6', '#2ECC71']
}
},
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: false
},
area: {
fill: { scale: 'color', ref: 'line' }
}
}
}
},
{
type: 'grid-line',
x: {
scale: 'x'
},
y: {
scale: 'y'
},
ticks: {
show: true,
stroke: 'grey',
strokeWidth: 0.2,
strokeDasharray: '3, 3'
},
minorTicks: {
show: false,
stroke: 'grey',
strokeWidth: 0.2
}
}
]
}
})