CxJS

Marker

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

Marker displays individual data points on a chart. Markers are commonly used for scatter charts and can be made draggable for interactive data manipulation. Click on legend entries to toggle visibility of each dataset.

<div controller={PageController} style="display: flex; gap: 16px">
  <Svg style="flex: 1; height: 400px">
    <Chart
      offset="20 -20 -40 40"
      axes={{
        x: { type: NumericAxis, snapToTicks: 1 },
        y: { type: NumericAxis, vertical: true, snapToTicks: 1 },
      }}
    >
      <Gridlines />
      <Repeater records={m.reds} recordAlias="$point">
        <Marker
          colorIndex={m.$point.color}
          legendColorIndex={1}
          active={m.showReds}
          name="Reds"
          size={m.$point.size}
          x={m.$point.x}
          y={m.$point.y}
          tooltip={{ tpl: "Red ({$point.x:n;0}, {$point.y:n;0})" }}
          style={{ fillOpacity: 0.5 }}
          draggableX
          draggableY
          shape="rect"
          rx={3}
        />
      </Repeater>
      <Repeater records={m.blues} recordAlias="$point">
        <Marker
          colorIndex={m.$point.color}
          legendColorIndex={5}
          active={m.showBlues}
          name="Blues"
          size={m.$point.size}
          x={m.$point.x}
          y={m.$point.y}
          tooltip={{ tpl: "Blue ({$point.x:n;0}, {$point.y:n;0})" }}
          style={{ fillOpacity: 0.5 }}
          draggableX
          draggableY
        />
      </Repeater>
    </Chart>
  </Svg>
  <Legend vertical />
</div>
Reds
Blues

Features

  • Multiple shapes: circle, square, rect, triangle
  • Variable size and color based on data
  • Draggable in X and/or Y direction with axis constraints
  • Tooltips on hover
  • Legend integration with visibility toggle

Configuration

PropertyTypeDefaultDescription
xnumberX-axis position.
ynumberY-axis position.
sizenumber5Marker size in pixels.
shapestring"circle"Shape: "circle", "square", "triangle".
colorIndexnumberColor palette index.
colorMapstringName of the color map to use.
colorNamestringName for color map lookup.
namestringName for legend. Also used as colorName if not set.
legendstring"legend"Legend name to show in.
activebooleantrueWhether the marker is active (visible).
draggableXbooleanfalseEnable horizontal dragging.
draggableYbooleanfalseEnable vertical dragging.
constrainbooleantrueConstrain dragging to chart bounds.
tooltipobjectTooltip configuration.
affectsAxesbooleantrueWhether marker position affects axis range calculation.