CxJS

Column

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

The Column component renders individual vertical bars. Unlike ColumnGraph which takes data arrays, Column is used with Repeater for more control over each column—such as individual colors based on value.

In this example, each column’s color is computed from its value using expr.

<div controller={PageController}>
  <Svg style="height: 350px; border: 1px dashed #ddd">
    <Chart
      margin="20 20 120 50"
      axes={{
        x: (
          <CategoryAxis labelRotation={-90} labelDy="0.4em" labelAnchor="end" />
        ),
        y: <NumericAxis vertical snapToTicks={1} />,
      }}
    >
      <Rectangle fill="white" />
      <Gridlines />
      <Repeater records={m.data} recordAlias="$point">
        <Column
          colorIndex={expr(
            m.$point.value,
            (v) => 15 - Math.round((v * 6) / 50),
          )}
          width={0.7}
          x={m.$point.city}
          y={m.$point.value}
          tooltip={format(m.$point.value, "n;1")}
        />
      </Repeater>
    </Chart>
  </Svg>
</div>

Configuration

PropertyTypeDescription
xstringCategory value.
ynumberColumn value (height).
y0numberColumn start value for range columns. Default is 0.
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.
widthnumberColumn 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.
tooltipobjectTooltip configuration.