CxJS

RangeMarker

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

RangeMarker displays range indicators on column or bar charts. Use different shapes to show maximum, minimum, or target values alongside the main data.

<div controller={PageController}>
  <div style="display: flex; flex-wrap: wrap; gap: 16px">
    <Svg style="flex: 1; min-width: 300px; height: 300px">
      <Chart
        offset="20 -20 -40 40"
        axes={{
          x: { type: CategoryAxis },
          y: { type: NumericAxis, vertical: true },
        }}
      >
        <Gridlines />
        <Repeater records={m.points} recordAlias="$point">
          <Column
            colorIndex={12}
            size={0.7}
            x={m.$point.category}
            y={m.$point.value}
            tooltip={{ tpl: "{$point.category} {$point.value:n;1}" }}
          />
          <RangeMarker
            x={m.$point.category}
            y={m.$point.max}
            lineStyle="stroke: blue"
            size={0.7}
            inflate={3}
            shape="max"
          />
          <RangeMarker
            x={m.$point.category}
            y={m.$point.min}
            lineStyle="stroke: red"
            size={0.7}
            inflate={3}
            shape="min"
          />
          <RangeMarker
            x={m.$point.category}
            y={m.$point.optimal}
            lineStyle="stroke: green"
            size={0.7}
            inflate={3}
            shape="line"
          />
        </Repeater>
      </Chart>
    </Svg>
    <Svg style="flex: 1; min-width: 300px; height: 300px">
      <Chart
        offset="20 -20 -40 40"
        axes={{
          x: { type: NumericAxis, snapToTicks: 0 },
          y: { type: CategoryAxis, vertical: true },
        }}
      >
        <Gridlines />
        <Repeater records={m.points} recordAlias="$point">
          <Bar
            colorIndex={13}
            size={0.7}
            x={m.$point.value}
            y={m.$point.category}
            tooltip={{ tpl: "{$point.category} {$point.value:n;1}" }}
          />
          <RangeMarker
            y={m.$point.category}
            x={m.$point.max}
            lineStyle="stroke: red"
            size={0.7}
            shape="max"
            inflate={3}
            vertical
          />
          <RangeMarker
            y={m.$point.category}
            x={m.$point.min}
            lineStyle="stroke: blue"
            size={0.7}
            shape="min"
            inflate={3}
            vertical
          />
          <RangeMarker
            y={m.$point.category}
            x={m.$point.optimal}
            lineStyle="stroke: green"
            size={0.7}
            shape="line"
            inflate={3}
            vertical
          />
        </Repeater>
      </Chart>
    </Svg>
  </div>
</div>

Shapes

  • "max" - Caret pointing up (columns) or right (bars) for maximum values
  • "min" - Caret pointing down (columns) or left (bars) for minimum values
  • "line" - Simple horizontal or vertical line for targets/averages

Configuration

PropertyTypeDefaultDescription
xnumberX-axis position (category or value).
ynumberY-axis position (value or category).
shapestring"line"Shape: "max", "min", or "line".
sizenumber0.5Width relative to column/bar (0-1).
inflatenumber0Pixels to extend beyond column/bar edges.
verticalbooleanfalseSet to true for horizontal bar charts.
lineStylestringCSS style string for the marker line.
lineClassstringCSS class for the marker line.