To make a stacked chart, you need to pass the stack
parameter to the seriesStyle
function used by the defaultStyle
or seriesStyle
parameters for plot. The stack
parameter takes a number
that serves as the id for the stack and stacks any series given that same id number. If you set stack
in defaultStyle
, this stack id will be applied to all of the series in your plot. If you set stack
in seriesStyles
, it'll stack any series given the same stack id number.
Here's an example of a line chart using demodata
:
filters
| demodata
| mapColumn "time" expression={getCell "time" | formatdate format="MMM YYYY"}
| pointseries x="time" y="mean(price)" color="state"
| plot defaultStyle={seriesStyle lines=1 fill=1 stack=1}
palette={palette "#1ea593" "#2b70f7" "#ce0060" "#38007e" "#fca5d3" "#f37020" "#e49e29" "#b0916f" "#7b000b" "#34130c" gradient=false}
| render
Here's an example as a bar chart using the same data:
filters
| demodata
| mapColumn "time" expression={getCell "time" | formatdate format="MMM YYYY"}
| pointseries x="time" y="mean(price)" color="state"
| plot defaultStyle={seriesStyle bars=0.5 fill=1 stack=1}
palette={palette "#1ea593" "#2b70f7" "#ce0060" "#38007e" "#fca5d3" "#f37020" "#e49e29" "#b0916f" "#7b000b" "#34130c" gradient=false}
| render
Here's an example with only the done
and running
series stacked:
filters
| demodata
| mapColumn "time" expression={getCell "time" | formatdate format="MMM YYYY"}
| pointseries x="time" y="mean(price)" color="state"
| plot defaultStyle={seriesStyle bars=0.5 fill=0.3}
seriesStyle={seriesStyle label="done" stack=1 fill=0.3}
seriesStyle={seriesStyle label="running" stack=1 fill=0.3}
palette={palette "#1ea593" "#2b70f7" "#ce0060" "#38007e" "#fca5d3" "#f37020" "#e49e29" "#b0916f" "#7b000b" "#34130c" gradient=false}
| render