"""Scatter chart template — fetch-and-adapt from d3-graph-gallery.com. Adapted from d3-graph-gallery.com (Yan Holtz) — https://d3-graph-gallery.com/graph/scatter_basic.html """ from __future__ import annotations from pydantic import BaseModel from app.agents.d3.registry import D3Template, register class Pt(BaseModel): x: float y: float label: str = "" class ScatterData(BaseModel): title: str = "" x_label: str = "" y_label: str = "" data: list[Pt] _HTML = """
""" golden_sample = ScatterData( title="Demo", x_label="X", y_label="Y", data=[ Pt(x=1, y=2, label="a"), Pt(x=2, y=4, label="b"), Pt(x=3, y=1, label="c"), ], ) register( D3Template( id="scatter", family="chart", title="Scatter plot", when_to_use="Show the relationship between two numeric variables across individual observations.", data_requirements="A set of (x, y) points, optionally labeled.", schema=ScatterData, html_template=_HTML, golden_sample=golden_sample, ) )