CxJS

Range

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

Range highlights important zones on the chart. Use x1/x2 to create a vertical band or y1/y2 to create a horizontal band. Drag the markers to adjust the range boundaries.

<div controller={PageController}>
  <Svg style="width: 100%; height: 400px">
    <Chart
      offset="20 -10 -40 40"
      axes={{
        x: { type: NumericAxis },
        y: { type: NumericAxis, vertical: true },
      }}
    >
      <Gridlines />
      <Range
        x1={m.p1.x}
        x2={m.p2.x}
        colorIndex={11}
        name="X Range"
        active={m.yrange}
      >
        <Text
          anchors="0 0.5 0 0.5"
          offset="5 0 0 0"
          textAnchor="middle"
          dominantBaseline="hanging"
        >
          X Range
        </Text>
      </Range>
      <Range
        y1={m.p1.y}
        y2={m.p2.y}
        colorIndex={8}
        name="Y Range"
        active={m.xrange}
      >
        <Text anchors="0.5 0 0.5 0" dominantBaseline="middle" dx={5}>
          Y Range
        </Text>
      </Range>
      <LineGraph data={m.points} colorIndex={0} />
      <Marker colorIndex={11} x={m.p1.x} size={10} draggableX />
      <Marker colorIndex={11} x={m.p2.x} size={10} draggableX />
      <Marker colorIndex={8} y={m.p1.y} size={10} draggableY />
      <Marker colorIndex={8} y={m.p2.y} size={10} draggableY />
    </Chart>
  </Svg>
  <Legend />
</div>
X Range
Y Range

Features

  • Vertical bands (x1/x2) or horizontal bands (y1/y2)
  • Labels inside ranges using child elements
  • Legend integration with visibility toggle
  • Combine with draggable Markers for interactive ranges

See Also

Configuration

PropertyTypeDefaultDescription
x1numberLeft boundary for vertical range.
x2numberRight boundary for vertical range.
y1numberBottom boundary for horizontal range.
y2numberTop boundary for horizontal range.
colorIndexnumberColor palette index.
colorMapstringName of the color map to use.
colorNamestringName for color map lookup.
namestringName for legend.
legendstring"legend"Legend name to show in.
activebooleantrueWhether the range is active (visible).
affectsAxesbooleantrueWhether range boundaries affect axis range.
styleobjectCSS style for the range rectangle.
classstringCSS class for the range element.