Stacked Chart
Learn how to create a stacked chart in Semaphor
Stacked Bar Chart
You can generate a stacked line, bar, or area chart using the following query structure.
- The first column (categorical or time-based) is mapped to the x-axis.
- The second column (categorical) values form a stack.
- The third column (numerical) represents a metric.
Stacked Line Chart
You can convert the above chart into a stacked line
by modifying the dataset.type
in the config as highlighted below.
Stacked Area Chart
Similarly, you can convert the above chart into an area chart by providing the fill
property as highlighted below.
Stacked Combo Chart
To create a stacked combo chart with dual axis, you'll need to structure your query as shown below.
The columns L1
, L2
, and L3
will be displayed as lines, while B1, B2, and B3 will be shown as stacked bars. We'll start by creating a basic bar chart and then modify it step by step.
Step 1 - Bars to Lines
Convert L1, L2, L3 columns into lines by changing the dataset type in the Y-axis settings.
Step 2 - Stack the Bars
And then stack the the bars by setting stacked
property to true
for both x
(options.scales.x)
and y
(options.scales.y)
axes in the chart config.
Step 3 - Dual Axis
You can further customize the chart by adding a secondary y-axis y1
for the lines
And then assign the y1
axis to the lines by setting the yAxisID
property in the dataset config like this:
See the docs for more details.
Step 4 - Axis Range
In some instances you might want to have different ranges for your y-axes. You can set this range by setting the min
and max
properties in the chart config.