Comparison Chart
A dual-series comparison spline chart with interactive touch scrubbing and tooltips.
// SYSTEM.STAGE
Installation
Install the component and its peer dependencies automatically via the CLI:
// SYS.USAGE
Drop this code into your screen or view:
1import ComparisonChart from "@/components/comparison-chart";2 3export default function PerformanceScreen() {4 const performanceData = [5 { label: "Jan 21", fullDate: "Sun, Jan 21", revenue: 3200, costs: 5800 },6 { label: "Jan 22", fullDate: "Mon, Jan 22", revenue: 3900, costs: 5100 },7 { label: "Jan 23", fullDate: "Tue, Jan 23", revenue: 4800, costs: 4300 },8 { label: "Jan 24", fullDate: "Wed, Jan 24", revenue: 5800, costs: 3600 },9 { label: "Jan 25", fullDate: "Thu, Jan 25", revenue: 6400, costs: 3300 },10 { label: "Jan 26", fullDate: "Fri, Jan 26", revenue: 6200, costs: 3800 },11 { label: "Jan 27", fullDate: "Sat, Jan 27", revenue: 5500, costs: 4700 },12 { label: "Jan 28", fullDate: "Sun, Jan 28", revenue: 4800, costs: 5800 },13 ];14 15 return (16 <ComparisonChart17 data={performanceData}18 series={[19 { key: "revenue", label: "revenue", color: "#32C798" },20 { key: "costs", label: "costs", color: "#818CF8" },21 ]}22 theme="dark"23 title="Revenue vs Costs"24 valuePrefix="$"25 height={220}26 onPointSelect={(point, index) => {27 console.log("Scrubbed point:", point, "at index:", index);28 }}29 />30 );31}// SPEC.PROPS_API
Configurable interfaces for <ComparisonChart />
| PROP_IDENTIFIER | TYPE_SIGNATURE | DEFAULT_VAL | TELEMETRY_NOTES |
|---|---|---|---|
| data | ComparisonDataPoint[] | DEFAULT_COMPARISON_DATA | Dataset containing multi-series numeric values, short x-axis labels, and full formatted dates. |
| series | SeriesConfig[] | DEFAULT_SERIES | Array defining each data series with key, display label, and line/indicator color. |
| theme | "dark" | "light" | "dark" | Color theme mode for card surface, grid lines, text tokens, and tooltip backdrop. |
| title | string | "Performance Overview" | Header title displayed above the comparative spline visualization. |
| valuePrefix | string | "$" | Prefix formatted before numerical metrics in the tooltip and legend (e.g. '$'). |
| valueSuffix | string | "" | Suffix formatted after numerical metrics in the tooltip and legend (e.g. ' pts'). |
| height | number | 220 | Height in pixels of the interactive SVG canvas area. |
| showTooltip | boolean | true | Whether to render the floating glassmorphic tooltip card that tracks the scrub cursor. |
| missingData | "interpolate" | "zero" | "gap" | "interpolate" | Strategy for handling null or undefined values in series data points ('interpolate' linearly estimates missing points smoothly, 'zero' plots missing values at 0, 'gap' gracefully interpolates). |
| accessibilityLabel | string | undefined | Custom accessibility narrative override for screen readers. |
| formatValue | (value: number) => string | undefined | Custom formatter function for numerical values in legend and tooltip. |
| onPointSelect | (point: ComparisonDataPoint, index: number) => void | undefined | Callback fired when a data point is scrubbed or tapped. |
Dataset containing multi-series numeric values, short x-axis labels, and full formatted dates.
DEFAULT_COMPARISON_DATAArray defining each data series with key, display label, and line/indicator color.
DEFAULT_SERIESColor theme mode for card surface, grid lines, text tokens, and tooltip backdrop.
"dark"Header title displayed above the comparative spline visualization.
"Performance Overview"Prefix formatted before numerical metrics in the tooltip and legend (e.g. '$').
"$"Suffix formatted after numerical metrics in the tooltip and legend (e.g. ' pts').
""Height in pixels of the interactive SVG canvas area.
220Whether to render the floating glassmorphic tooltip card that tracks the scrub cursor.
trueStrategy for handling null or undefined values in series data points ('interpolate' linearly estimates missing points smoothly, 'zero' plots missing values at 0, 'gap' gracefully interpolates).
"interpolate"Custom accessibility narrative override for screen readers.
undefinedCustom formatter function for numerical values in legend and tooltip.
undefinedCallback fired when a data point is scrubbed or tapped.
undefined// PERFORMANCE_&_A11Y
Native touch gestures, screen reader attributes, and 60–120 FPS frame budgets: