Constructor
Creates a new scatter series instance.Properties
Color of the scatter points. Defaults to Indigo-600.
Name of the series displayed in the legend.
Whether the series is visible on the chart.
Array of data points to render. Each point has
x and y properties.Radius of each scatter point in pixels.
Downsampled data points actually rendered. Uses LTTB algorithm for datasets over 2000 points.
Scale instance for X-axis coordinate transformation.
Scale instance for Y-axis coordinate transformation.
Whether animations are enabled for this series.
Duration of animations in milliseconds.
Methods
setData
Updates the series data and triggers animation if enabled.Array of data points where each point contains
x and y values.setScales
Sets the X and Y scales for coordinate transformation.Scale instance for X-axis transformation.
Scale instance for Y-axis transformation.
render
Renders the scatter series on the canvas. Called automatically during the chart render cycle.enableAnimation
Enables animation for the series with an optional custom duration.Animation duration in milliseconds.
disableAnimation
Disables animation for the series.startAnimation
Manually triggers the render animation.getDataAt
Returns the data point closest to the given position within a threshold.Position to query, typically mouse coordinates in pixels.
The closest data point within a 10-pixel threshold based on 2D Euclidean distance, or null if none found.
Data format
Scatter series accepts an array of Point objects:Configuration
When using the Chart API, configure scatter series through the series config:ScatterSeriesConfig
Point radius
Customize the size of scatter points:Performance
Scatter series automatically downsamples datasets with more than 2000 points using the LTTB (Largest-Triangle-Three-Buckets) algorithm. This maintains visual distribution while improving rendering performance. This only applies to numeric X values; categorical data is not downsampled. Points outside the visible canvas area are automatically skipped during rendering for additional performance optimization.Hit testing
ThegetDataAt method uses 2D Euclidean distance to find the closest point to the mouse position. For categorical X scales, it performs a linear scan. For numeric X scales, it uses binary search optimization before calculating 2D distances.
The hit detection threshold is 10 pixels in both directions.
Animation
By default, scatter series animates on initial render and data updates. The animation:- Uses easeOutCubic easing function
- Progressively renders points from left to right
- Duration is 600ms by default
- Can be customized or disabled
Use cases
Scatter plots are ideal for:- Visualizing correlations between two variables
- Identifying clusters and outliers in data
- Displaying distribution patterns
- Comparing multiple discrete data points
- Scientific and statistical analysis