CxJS

ColumnGraph

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

The ColumnGraph component renders a series of vertical bars. Use with CategoryAxis on the X axis for category labels.

For multiple series, use size and offset to position columns side by side. 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={1} />,
      }}
    >
      <Rectangle fill="white" />
      <Gridlines />
      <ColumnGraph
        name="Q1"
        data={m.data}
        colorIndex={0}
        xField="month"
        yField="q1"
        size={0.3}
        offset={-0.15}
        active={m.q1Active}
      />
      <ColumnGraph
        name="Q2"
        data={m.data}
        colorIndex={5}
        xField="month"
        yField="q2"
        size={0.3}
        offset={0.15}
        active={m.q2Active}
      />
    </Chart>
  </Svg>
</div>
Q1
Q2

Configuration

PropertyTypeDescription
dataarrayArray of data points.
xFieldstringField name for the category. Default is "x".
yFieldstringField name for the column value (height). Default is "y".
colorIndexnumberIndex of the color from the theme palette.
colorMapstringName of the color map for automatic color assignment.
namestringSeries name for the legend.
activebooleanBinding to control visibility. Works with Legend interaction.
sizenumberColumn width as a fraction of available space. Default is 0.5.
offsetnumberOffset for positioning multiple series. Default is 0.
stackedbooleanSet to true to stack columns.
borderRadiusnumberCorner radius for rounded columns.
y0FieldstringField name for the column start value (for range columns).
selectionobjectSelection configuration for interactive columns.