CxJS

Stacked Columns

import { Column } from 'cx/charts'; Copied

Stacked column charts display multiple data series stacked vertically. Set stacked to true on each Column to enable stacking.

Click legend entries to toggle series visibility.

<div controller={PageController}>
  <Legend />
  <Svg style="height: 300px; border: 1px dashed #ddd">
    <Chart
      margin="20 20 40 50"
      axes={{
        x: <CategoryAxis />,
        y: <NumericAxis vertical snapToTicks={0} />,
      }}
    >
      <Rectangle fill="white" />
      <Gridlines />
      <Repeater records={m.data} recordAlias="$point">
        <Column
          name="Q1"
          colorIndex={0}
          width={0.6}
          x={m.$point.month}
          y={m.$point.q1}
          stacked
          tooltip={format(m.$point.q1, "n;0")}
          active={m.q1Active}
        />
        <Column
          name="Q2"
          colorIndex={5}
          width={0.6}
          x={m.$point.month}
          y={m.$point.q2}
          stacked
          tooltip={format(m.$point.q2, "n;0")}
          active={m.q2Active}
        />
        <Column
          name="Q3"
          colorIndex={10}
          width={0.6}
          x={m.$point.month}
          y={m.$point.q3}
          stacked
          tooltip={format(m.$point.q3, "n;0")}
          active={m.q3Active}
        />
      </Repeater>
    </Chart>
  </Svg>
</div>
Q1
Q2
Q3

Configuration

PropertyTypeDescription
stackedbooleanSet to true to stack this column on top of previous ones.
stackstringName of the stack group. Default is "stack". Use different names to create multiple stacks side by side.
activebooleanBinding to control visibility. Works with Legend interaction.