Scatter Chart with Integrated Zoom Overlay - Editor

This example visualizes the relationship between price and carat weight across 53,940 diamonds. The data is categorized by clarity, using a color lookup table. Distinct vertical clusters at round-number weights (e.g., 1.0ct) show clear price jumps, marking where consumer demand for specific sizes creates market premiums.

An overview chart in the upper left corner displays the full dataset and indicates the current zoom level of the main chart. The zoom rectangle inside the overview chart can be resized and moved.

When the application launches, a screenshot of the main ChartXY is captured as a data URL and applied as the background fill for the overview chart. The background image updates automatically when the browser window is resized.

const screenshotDataUrl = chart.engine.captureFrame(undefined, undefined, true)
const img = new Image();
img.src = screenshotDataUrl
const fill = new ImageFill({ source: img })
overlayChart.setSeriesBackgroundFillStyle(fill)

The data used in this example: Tidyverse / Diamonds CSV.