"""Multi-line chart template — fetch-and-adapt from d3-graph-gallery.com. Adapted from d3-graph-gallery.com (Yan Holtz) — https://d3-graph-gallery.com/graph/line_several_group.html """ from __future__ import annotations from pydantic import BaseModel from app.agents.d3.registry import D3Template, register class Point(BaseModel): x: float y: float class Series(BaseModel): name: str points: list[Point] class MultiLineData(BaseModel): title: str = "" x_label: str = "" y_label: str = "" series: list[Series] _HTML = """
""" golden_sample = MultiLineData( title="Demo", x_label="Time", y_label="Value", series=[ Series(name="Series A", points=[Point(x=0, y=1), Point(x=1, y=3), Point(x=2, y=2)]), Series(name="Series B", points=[Point(x=0, y=2), Point(x=1, y=1), Point(x=2, y=4)]), ], ) register( D3Template( id="multi_line", family="chart", title="Multi-line chart", when_to_use="Compare several named series each changing over the same ordered/continuous axis.", data_requirements="Two or more named series, each a sequence of (x, y) points.", schema=MultiLineData, html_template=_HTML, golden_sample=golden_sample, ) )