CxJS

ScatterGraph

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

ScatterGraph renders scatter plots from an array of data points. Unlike Marker which renders individual points, ScatterGraph efficiently renders entire datasets and is better suited for visualizing large amounts of data.

<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 />
      <ScatterGraph
        data={m.reds}
        name="Reds"
        colorIndex={1}
        shape="square"
        sizeField="size"
        active={m.showReds}
      />
      <ScatterGraph
        data={m.blues}
        name="Blues"
        colorIndex={5}
        sizeField="size"
        active={m.showBlues}
      />
    </Chart>
  </Svg>
  <Legend vertical />
</div>
Reds
Blues

Features

  • Efficient rendering of large datasets
  • Variable point size based on data field
  • Multiple shapes: circle, square, triangle
  • Legend integration with visibility toggle

Configuration

PropertyTypeDefaultDescription
dataarrayArray of data points.
xFieldstring"x"Field name for x-axis values.
yFieldstring"y"Field name for y-axis values.
sizeFieldstringField name for point size.
sizenumber5Default point size when sizeField not set.
shapestring"circle"Shape: "circle", "square", "triangle".
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 graph is active (visible).