CxJS

Normalized Columns

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

Normalized stacked column charts show proportions as percentages. Each stack totals to 100%, making it easy to compare relative contributions across categories.

Set normalized to true on the NumericAxis and use format="p;0" to display percentages.

<div controller={PageController}>
  <Legend />
  <Svg style="height: 300px; border: 1px dashed #ddd">
    <Chart
      margin="20 20 40 50"
      axes={{
        x: <CategoryAxis />,
        y: <NumericAxis vertical normalized format="p;0" />,
      }}
    >
      <Rectangle fill="white" />
      <Gridlines />
      <Repeater records={m.data} recordAlias="$point">
        <Column
          name="Product A"
          colorIndex={0}
          x={m.$point.year}
          y={m.$point.v1}
          stacked
          tooltip={format(m.$point.v1, "n;0")}
          active={m.v1Active}
        />
        <Column
          name="Product B"
          colorIndex={5}
          x={m.$point.year}
          y={m.$point.v2}
          stacked
          tooltip={format(m.$point.v2, "n;0")}
          active={m.v2Active}
        />
        <Column
          name="Product C"
          colorIndex={10}
          x={m.$point.year}
          y={m.$point.v3}
          stacked
          tooltip={format(m.$point.v3, "n;0")}
          active={m.v3Active}
        />
      </Repeater>
    </Chart>
  </Svg>
</div>
Product A
Product B
Product C

Configuration

PropertyTypeDescription
normalizedbooleanSet on NumericAxis to normalize stacked values to 100%.
formatstringSet to "p;0" on axis to display percentage labels.
stackedbooleanSet on Column to enable stacking.