CxJS

Swimlane

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

Swimlane creates individual swimlane bands where each one can have unique properties or content. Use with a Repeater to create swimlanes for each data record. Unlike Swimlanes (plural), this component gives you full control over each lane.

<div controller={PageController}>
  <div style="display: flex; flex-wrap: wrap; gap: 16px">
    <Svg style="flex: 1; min-width: 300px; height: 350px">
      <Chart
        offset="20 -20 -20 40"
        axes={{
          x: { type: CategoryAxis, hidden: true },
          y: { type: NumericAxis, vertical: true },
        }}
      >
        <Repeater records={m.points} recordAlias="$point" indexAlias="$index">
          <Swimlane size={0.8} x={m.$point.category} vertical>
            <Text
              value={m.$point.category}
              anchors="0.5 0.5 0.5 0.5"
              dominantBaseline="middle"
              textAnchor="middle"
              style="fill: #888; transform: rotate(-90deg); transform-box: fill-box; transform-origin: center"
            />
          </Swimlane>
        </Repeater>
      </Chart>
    </Svg>
    <Svg style="flex: 1; min-width: 300px; height: 350px">
      <Chart
        offset="20 -20 -40 20"
        axes={{
          x: { type: NumericAxis, snapToTicks: 0 },
          y: { type: CategoryAxis, vertical: true, hidden: true },
        }}
      >
        <Repeater records={m.points} recordAlias="$point">
          <Swimlane size={0.8} y={m.$point.category}>
            <Text
              value={m.$point.category}
              anchors="0.5 0 0.5 0"
              dx={5}
              dominantBaseline="middle"
              style="fill: #888"
            />
          </Swimlane>
        </Repeater>
      </Chart>
    </Svg>
  </div>
</div>

When to Use

  • Swimlane (this) - When you need individual control over each lane (different colors, content inside lanes, custom styling per lane)
  • Swimlanes - When you want automatic background bands for readability

Configuration

PropertyTypeDefaultDescription
xstringCategory value for vertical swimlane position.
ystringCategory value for horizontal swimlane position.
sizenumber1Swimlane width relative to category step (0-1).
verticalbooleanfalseSet to true for vertical swimlanes.
colorIndexnumberBackground color from the palette.
styleobjectCSS style for the swimlane rectangle.
classstringCSS class for the swimlane element.