CxJS

MarkerLine

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

MarkerLine draws horizontal or vertical lines to highlight important values such as minimum, maximum, thresholds, or averages. Child elements (like Text) can be placed inside to add labels.

<div controller={PageController}>
  <Svg style="width: 100%; height: 350px">
    <Chart
      offset="20 -10 -40 40"
      axes={{
        x: { type: NumericAxis },
        y: { type: NumericAxis, vertical: true, deadZone: 20 },
      }}
    >
      <Gridlines />
      <MarkerLine y={m.extremes.min} colorIndex={6}>
        <Text anchors="0 0 0 0" offset="5 0 0 5" dominantBaseline="hanging">
          Min
        </Text>
      </MarkerLine>
      <MarkerLine y={m.extremes.max} colorIndex={3}>
        <Text anchors="0 0 0 0" offset="-5 0 0 5">
          Max
        </Text>
      </MarkerLine>
      <LineGraph data={m.points} colorIndex={0} />
    </Chart>
  </Svg>
  <Legend />
  <Button onClick="generate">Generate</Button>
</div>

Note how deadZone is used on the vertical axis to reserve space for min/max labels.

Configuration

PropertyTypeDefaultDescription
xnumberDraw a vertical line at this x value.
ynumberDraw a horizontal line at this y value.
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 line is active (visible).
affectsAxesbooleantrueWhether line position affects axis range.
lineStylestringCSS style string for the line.
classstringCSS class for the line element.