Block 259 of 297
Scatter Plot
Plot items on two measures with optional dot sizes, a least-squares trend line and labelled outliers.
- Puck key
- ScatterPlotBlock
- Export
- scatterPlotBlock
- React component
- <ScatterPlot />
- Path
- components/puck/scatter-plot-block.tsx
- Dependencies
- None
- License
- MIT
About this block
When to use it, how to write for it, and what to change in the code.
What it's for
Plots items against two measures to show whether they move together, with an optional least-squares trend line, its slope and R² in the key. Dots can be sized by a third number, and up to three points that sit far from the trend can be labeled automatically. Points accept {{ item.field }} bindings from a P1 data source list.
- Tutoring hours against reading growth across schools
- Cost per participant against outcomes for several programs
- Branch size against visits, sized by population
Writing the content
- Fill X-axis title and Y-axis title with what each position means, like "Tutoring hours per student".
- Label outliers needs at least five points and flags only points well off the trend, up to three. Points accept up to 60 entries.
- Leave Size (optional) blank on all points for equal dots, or fill all of them and set Size means.
- A trend line shows correlation, not cause; say so in the Footnote if readers might assume otherwise.
Accessibility
- The plot has role="img" with a summary of the point count, both ranges, the trend slope and R², and any labeled outliers.
- "View data table" lists every point with its X, Y, size and an outlier note in a real table (WCAG 1.3.1).
- Outliers are named in text on the plot and in the table, not marked by a darker dot alone (WCAG 1.4.1).
Customizing the code
- The outlier threshold is 1.6 times the residual standard deviation, set in the render function; the cap of three follows it.
- Plot height is PLOT_HEIGHT (h-56 @md:h-72), and dot size runs from 8 to 24px in diameter().
Editor fields
What content editors see in the P1 sidebar when they select this block.
- Titletext
- Heading levelselect
- Subtitle or periodtext
- Pointsarray
- X-axis titletext
- Y-axis titletext
- X unittext
- Y unittext
- Size meanstext
- Trend lineradio
- Label outliersradio
- Footnotetext