Skip to content

πŸͺ’ Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

refactor(web): Remove recharts dependency (#17889)

Ben Bachem11c80fc211e0
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index f12ec726da..ef64f0eb1e 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -877,9 +877,6 @@ importers:
react18-json-view:
specifier: ^0.2.8-canary.6
version: 0.2.8-canary.6([email protected])
- recharts:
- specifier: ^3.8.0
remark-gfm:
specifier: ^4.0.1
version: 4.0.1([email protected])
@@ -5425,17 +5422,6 @@ packages:
peerDependencies:
react: ^18.0 || ^19.0 || ^19.0.0-rc
- '@reduxjs/[email protected]':
- resolution: {integrity: sha512-Kd6kAHTA6/nUpp8mySPqj3en3dm0tdMIgbttnQ1xFMVpufoj+ADi8pXLBsd4xzTRHQa7t/Jv8W5UnCuW4kuWMQ==}
- peerDependencies:
- react: ^16.9.0 || ^17.0.0 || ^18 || ^19
- react-redux: ^7.2.1 || ^8.1.3 || ^9.0.0
- peerDependenciesMeta:
- react:
- optional: true
- react-redux:
- optional: true
-
'@release-it/[email protected]':
resolution: {integrity: sha512-vzKrEGPac/yim5WUjMmIQ9k+n3NlWHYraUIlLkHna2Ka0+zmmB1peW8POMjA6Fb7TwcIsNMuoXj2wLc8NFzgRg==}
engines: {node: ^20.19.0 || ^22.13.0 || >=24.0.0}
@@ -6694,9 +6680,6 @@ packages:
resolution: {integrity: sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==}
- '@types/[email protected]':
- resolution: {integrity: sha512-zFDAD+tlpf2r4asuHEj0XH6pY6i0g5NeAHPn+15wk3BV6JA69eERFXC1gyGThDkVa1zCyKr5jox1+2LbV/AMLg==}
-
resolution: {integrity: sha512-7gqG38EyHgyP1S+7+xomFtL+ZNHcKv6DwNaCZmJmo1vgMugyF3TCnXVg4t1uk89mLNwnLtnY3TpOpCOyp1/xHQ==}
@@ -8177,9 +8160,6 @@ packages:
supports-color:
optional: true
- resolution: {integrity: sha512-qIMFpTMZmny+MMIitAB6D7iVPEorVw6YQRWkvarTkT4tBeSLLiHzcwj6q0MmYSFCiVpiqPJTJEYIrpcPzVEIvg==}
-
resolution: {integrity: sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==}
@@ -9326,9 +9306,6 @@ packages:
engines: {node: '>=16.x'}
hasBin: true
- resolution: {integrity: sha512-d/+XTN3zfODyjr89gM3mPq1WNX2B8pYsu7eORitdwyA2sBubnTl3laYlBk4sXY5FUa5qTZGBDPJICVbvqzjlbw==}
-
resolution: {integrity: sha512-XREFCPo6ksxVzP4E0ekD5aMdf8WMwmdNaz6vuvxgI40UaEiu6q3p8X52aU6GdyvLY3XXX/8R7JOTXStz/nBbRw==}
@@ -11155,9 +11132,6 @@ packages:
resolution: {integrity: sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==}
- resolution: {integrity: sha512-W+EWGn2v0ApPKgKKCy/7s7WHXkboGcsrXE+2joLyVxkbyVQfO3MUEaUQDHoSmb8TFFrSKYa9mw64WZHNHSDzYA==}
-
resolution: {integrity: sha512-qKxVopLT/TyA6BX3Ue5NwabOsAzm0Q7kAPwq6L+wWDwisYs7R8vZ0nRXqq6rkueboxpkjvLGU9fWifiX/ZZFxQ==}
peerDependencies:
@@ -11167,18 +11141,6 @@ packages:
resolution: {integrity: sha512-I42jl7L3Ze6kZaq+7zXWSunBa3b1on5yfvUW6Eo/3fFOj6dZ5Bqmcd264nJbTK/gn1HjjILAjSwnZbV4RpSaNQ==}
- resolution: {integrity: sha512-KQopgqFo/p/fgmAs5qz6p5RWaNAzq40WAu7fJIXnQpYxFPbJYtsJPWvGeF2rOBaY/kEuV77AVsX8TsQzKm+A/g==}
- peerDependencies:
- '@types/react': ^18.2.25 || ^19
- react: ^18.0 || ^19
- redux: ^5.0.0
- peerDependenciesMeta:
- '@types/react':
- optional: true
- redux:
- optional: true
-
resolution: {integrity: sha512-z6F7K9bV85EfseRCp2bzrpyQ0Gkw1uLoCel9XBVWPg/TjRj94SkJzUTGfOa4bs7iJvBWtQG0Wq7wnI0syw3EBQ==}
engines: {node: '>=0.10.0'}
@@ -11256,14 +11218,6 @@ packages:
resolution: {integrity: sha512-mFAyJq9vUbSTARLZUvAEf1z3YxlvAwswbmxMx2mPA/MSm4KmpwvwvhsH/NIrZhyOuwD60Lzyw2qh83uCbgTPYw==}
engines: {node: '>= 4'}
- resolution: {integrity: sha512-Z/m38DX3L73ExO4Tpc9/iZWHmHnlzWG4njQbxsF5aSjwqmHNDDIm0rdEBArkwsBvR8U6EirlEHiQNYWCVh9sGQ==}
- engines: {node: '>=18'}
- peerDependencies:
- react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
- react-dom: ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
- react-is: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
-
resolution: {integrity: sha512-/vxpCXddiX8NGfGO/mTafwjq4aFa/71pvamip0++IQk3zG8cbCj0fifNPrjjF1XMXUne91jL9OoxmdykoEtifQ==}
engines: {node: '>= 10.13.0'}
@@ -11280,14 +11234,6 @@ packages:
resolution: {integrity: sha512-DJnGAeenTdpMEH6uAJRK/uiyEIH9WVsUmoLwzudwGJUwZPp80PDBWPHXSAGNPwNvIXAbe7MSUB1zQFugFml66A==}
engines: {node: '>=4'}
- resolution: {integrity: sha512-NW2r5T6ksUKXCabzhL9z+h206HQw/NJkcLm1GPImRQ8IzfXwRGqjVhKJGauHirT0DAuyy6hjdnMZaRoAcy0Klw==}
- peerDependencies:
- redux: ^5.0.0
-
- resolution: {integrity: sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==}
-
resolution: {integrity: sha512-00o4I+DVrefhv+nX0ulyi3biSHCPDe+yLv5o/p6d/UVlirijB8E16FtfwSAi4g3tcqrQ4lRAqQSoFEZJehYEcw==}
engines: {node: '>= 0.4'}
@@ -11356,9 +11302,6 @@ packages:
resolution: {integrity: sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==}
- resolution: {integrity: sha512-K/BG6eIky/SBpzfHZv/dd+9JBFiS4SWV7FIujVyJRux6e45+73RaUHXLmIR1f7WOMaQ0U1km6qwklRQxpJJY0w==}
-
resolution: {integrity: sha512-yE7KUfFvaBFzGPs5H3Ops1RevfUEsDc5Iz65rOwWg4lE8HJSYtle77uul3+573457oHvBKuHYDl/xqUkKpEEdw==}
engines: {node: '>=18'}
@@ -12361,9 +12304,6 @@ packages:
resolution: {integrity: sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==}
- resolution: {integrity: sha512-SbPDPdDBYp+5MJHhBCAyI7wKM3d5ivekigc2Dk2s7pgbZ9wIgIBYGVw4zGHBml/qTFbexrofXW6Gu4noGxrOwQ==}
-
resolution: {integrity: sha512-emY992wwyOfG5kDEmo7br/OWCz8YMOYhc/0YQo/vGdSqYQhTCRSvHHjjeysAr6co1F2cyoK50szd4nMitZ0k8w==}
peerDependencies:
@@ -16976,18 +16916,6 @@ snapshots:
dependencies:
react: 19.2.4
- dependencies:
- '@standard-schema/spec': 1.1.0
- '@standard-schema/utils': 0.3.0
- immer: 11.1.4
- redux: 5.0.1
- redux-thunk: 3.1.0([email protected])
- reselect: 5.1.1
- optionalDependencies:
- react: 19.2.4
-
dependencies:
'@decimalturn/toml-patch': 1.3.0
@@ -18466,8 +18394,6 @@ snapshots:
'@types/[email protected]': {}
- '@types/[email protected]': {}
-
'@types/[email protected]': {}
'@types/[email protected]': {}
@@ -20142,8 +20068,6 @@ snapshots:
optionalDependencies:
supports-color: 8.1.1
-
@@ -21667,9 +21591,8 @@ snapshots:
-
+ optional: true
dependencies:
@@ -23824,8 +23747,6 @@ snapshots:
-
dependencies:
'@types/hast': 3.0.4
@@ -23848,15 +23769,6 @@ snapshots:
dependencies:
fast-deep-equal: 2.0.1
- dependencies:
- '@types/use-sync-external-store': 0.0.6
- react: 19.2.4
- use-sync-external-store: 1.6.0([email protected])
- optionalDependencies:
- '@types/react': 19.2.14
- redux: 5.0.1
-
@@ -23930,26 +23842,6 @@ snapshots:
tiny-invariant: 1.3.3
tslib: 2.8.1
- dependencies:
- clsx: 2.1.1
- decimal.js-light: 2.5.1
- es-toolkit: 1.52.0
- eventemitter3: 5.0.4
- immer: 10.2.0
- react: 19.2.4
- react-dom: 19.2.4([email protected])
- react-is: 19.2.4
- reselect: 5.1.1
- tiny-invariant: 1.3.3
- use-sync-external-store: 1.6.0([email protected])
- victory-vendor: 37.3.6
- transitivePeerDependencies:
- - '@types/react'
- - redux
-
dependencies:
resolve: 1.22.12
@@ -23965,12 +23857,6 @@ snapshots:
dependencies:
redis-errors: 1.2.0
- dependencies:
- redux: 5.0.1
-
-
dependencies:
call-bind: 1.0.8
@@ -24113,8 +23999,6 @@ snapshots:
-
@@ -25270,23 +25154,6 @@ snapshots:
'@types/unist': 3.0.3
vfile-message: 4.0.3
- dependencies:
- '@types/d3-array': 3.2.2
- '@types/d3-ease': 3.0.2
- '@types/d3-interpolate': 3.0.4
- '@types/d3-scale': 4.0.9
- '@types/d3-shape': 3.2.0
- '@types/d3-time': 3.0.4
- '@types/d3-timer': 3.0.2
- d3-array: 3.2.4
- d3-ease: 3.0.1
- d3-interpolate: 3.0.1
- d3-scale: 4.0.2
- d3-shape: 3.2.0
- d3-time: 3.1.0
- d3-timer: 3.0.1
-
dependencies:
'@next/env': 16.3.0-preview.5
diff --git a/web/package.json b/web/package.json
index 21275d68dc..6916ec1fc8 100644
--- a/web/package.json
+++ b/web/package.json
@@ -162,7 +162,6 @@
"react-resizable-panels": "^4.8.0",
"react-responsive": "^10.0.1",
"react18-json-view": "^0.2.8-canary.6",
- "recharts": "^3.8.0",
"remark-gfm": "^4.0.1",
"rxjs": "7.8.1",
"sonner": "^2.0.7",
diff --git a/web/src/features/widgets/chart-library/ChartingPrinciples.mdx b/web/src/features/widgets/chart-library/ChartingPrinciples.mdx
deleted file mode 100644
index 29ec12a62e..0000000000
--- a/web/src/features/widgets/chart-library/ChartingPrinciples.mdx
+++ /dev/null
@@ -1,123 +0,0 @@
-import { Meta, Canvas } from "@storybook/addon-docs/blocks";
-import * as Principles from "./ChartingPrinciples.stories";
-
-<Meta title="Charting Principles" />
-
-# Charting Principles
-
-The data carries the weight. The frame stays quiet.
-
-A chart here is not a picture we compose by hand. It is the last step of a
-pipeline: **data -> prepare -> visualise -> pixels**. The renderer decides
-nothing. These eight moves are what the _prepare_ step decides so that any
-data, from one clean series to two hundred noisy ones, comes out legible.
-Argue with them in the preparer, never in the chart component.
-
-## 1. Draw what was measured
-
-Straight segments are the honest default because they claim only the points we
-have. A smooth curve **invents values that were never sampled**; use it only
-when you mean to. Stepped lines are for data that holds until it changes, like
-states or counters. The line is a record, not a decoration.
-
-<Canvas of={Principles.Interpolation} sourceState="none" />
-
-## 2. Missing is a gap, not a zero
-
-A null breaks the line. Substituting `0` to fill the hole manufactures a
-measurement that never happened, which is the single most common way a chart
-lies. Bridge a gap only when the series genuinely continues across it. Zero is
-a value, not a synonym for absence.
-
-<Canvas of={Principles.NullHandling} sourceState="none" />
-
-In production the choice is not made per chart β€” **the metric's aggregation
-decides it**. Counts and sums have an honest zero (nothing happened), so a
-missing bucket fills with a real `0` and the line stays continuous. Averages
-and percentiles have no honest value there, so the cell becomes `null` and the
-line breaks. The same missing buckets, two truthful renderings:
-
-<Canvas of={Principles.GapVersusZero} sourceState="none" />
-
-Bridging (`connectNulls`) exists, but as an explicit opt-in β€” never the
-default:
-
-<Canvas of={Principles.HonestVersusBridged} sourceState="none" />
-
-Each series breaks over its own missing buckets while the others keep drawing,
-and a bucket in which nothing measured anything **stays on the axis** β€” the
-empty era is visible instead of time silently compressing away:
-
-<Canvas of={Principles.StaggeredSeriesGaps} sourceState="none" />
-
-<Canvas of={Principles.EmptyBucketsStayOnAxis} sourceState="none" />
-
-Honest gaps must never hide real data. A value with no drawable neighbor spans
-no line segment, so it gets a dot β€” the only mark that keeps it visible. Areas
-follow the same grammar:
-
-<Canvas of={Principles.IsolatedPoints} sourceState="none" />
-
-<Canvas of={Principles.AreaGaps} sourceState="none" />
-
-## 3. Show certainty in the ink
-
-A still-aggregating final bucket and a previous-period comparison are real, but
-they are **less certain** than confirmed history. Do not drop them and do not
-draw them as solid fact. Render them dotted and paled, and use that treatment
-consistently so a reader learns the grammar once.
-
-<Canvas of={Principles.Certainty} sourceState="none" />
-
-## 4. Hover is a timeline, not a panel
-
-The cursor between two points must never conjure a reading that is not there.
-The crosshair tracks the cursor, the value snaps to the nearest real sample,
-and near a gap the snap tightens so a tooltip never floats over emptiness.
-Charts on one time range share one vertical marker; only the chart under the
-cursor opens a tooltip.
-
-<Canvas of={Principles.HoverTimeline} sourceState="none" />
-
-## 5. Color is identity
-
-A series color belongs to the series, not to its position in a list. Derive it
-once and let the legend read it back so swatch and line can never diverge, and
-the same entity keeps its color across every chart on the board. The palette is
-bounded, and a colorblind-safe option always exists.
-
-## 6. Trust the scale
-
-Numbers, durations, bytes, percentages, currency, and dates each format by
-their kind and by the magnitude the scale chose. One unit per axis. Tick
-precision follows the scale, tooltip precision is capped for reading, and
-digits are tabular so they do not jitter. Do not out-clever the axis engine;
-format the spacing it gives you.
-
-<Canvas of={Principles.QuietChrome} sourceState="none" />
-
-## 7. Spend ink on data
-
-Faint horizontal gridlines, no axis spine, muted labels, no data-point dots by
-default, fills barely there, and no animation on the series. Every pixel of
-chrome is a pixel stolen from the data. The grid is scaffolding: build the
-building, then take the scaffolding down.
-
-## 8. Bound the frame, not the data
-
-Two hundred series is not a chart; it is a wall. Draw a legible top-N, roll it
-by magnitude, and state the truth in the open: _showing top 25 of 487_. Bound
-the legend, bound the density upstream at about one point per pixel, and never
-buy legibility by silently throwing data away where no one can see you do it.
-
-<Canvas of={Principles.BoundTheFrame} sourceState="none" />
-
-## Summary
-
-One adaptable pipeline. No special cases.
-
-Teach the preparer a new shape, never the component a new exception.
-
-The full architecture and the one-way **data -> prepare -> visualise** rule
-live in `web/src/features/widgets/chart-library/ARCHITECTURE.md`. For how
-overlays escape the chart frame, see `web/src/context/LayerContext/LayerContext.tsx`.
diff --git a/web/src/features/widgets/chart-library/ChartingPrinciples.stories.tsx b/web/src/features/widgets/chart-library/ChartingPrinciples.stories.tsx
deleted file mode 100644
index d47bb732bb..0000000000
--- a/web/src/features/widgets/chart-library/ChartingPrinciples.stories.tsx
+++ /dev/null
@@ -1,610 +0,0 @@
-import preview from "../../../../.storybook/preview";
-import {
- CartesianGrid,
- Line,
- LineChart,
- ResponsiveContainer,
- XAxis,
- YAxis,
-} from "recharts";
-import { AreaChartTimeSeries } from "./AreaChartTimeSeries";
-import { LineChartTimeSeries } from "./LineChartTimeSeries";
-import { formatMetric } from "./utils";
-import { type DataPoint, type MetricFormatterFunction } from "./chart-props";
-
-/**
- * Illustrations for the charting-principles article (`ChartingPrinciples.mdx`).
- * The didactic ones (interpolation, null handling, certainty) draw raw recharts
- * so the contrast is unmistakable; the rest reuse the real
- * `LineChartTimeSeries` so the article shows production behavior, not a mockup.
- * Deterministic data only β€” no Math.random β€” so the renders are stable.
- */
-
-// ── shared didactic data ─────────────────────────────────────────────────────
-// Sparse + jagged so the interpolation choice is obvious at a glance.
-const sparse = [
- { x: "1", y: 20 },
- { x: "2", y: 82 },
- { x: "3", y: 34 },
- { x: "4", y: 90 },
- { x: "5", y: 46 },
- { x: "6", y: 68 },
-];
-
-const ExampleCard = ({
- label,
- caption,
- tall = false,
- children,
-}: {
- label: string;
- caption: string;
- /** Production-component demos need room for legends + axis labels. */
- tall?: boolean;
- children: React.ReactNode;
-}) => (
- <div
- className={
- tall
- ? "flex min-w-[340px] flex-1 flex-col gap-1"
- : "flex min-w-[210px] flex-1 flex-col gap-1"
- }
- >
- <div className="text-xs font-bold tracking-wide uppercase">{label}</div>
- <div
- className={
- tall
- ? "bg-background h-[240px] w-full rounded-md border p-2"
- : "bg-background h-[150px] w-full rounded-md border p-2"
- }
- >
- {children}
- </div>
- <div className="text-muted-foreground w-full text-xs">{caption}</div>
- </div>
-);
-
-const axes = (
- <>
- <CartesianGrid stroke="hsl(var(--chart-grid))" vertical={false} />
- <XAxis
- dataKey="x"
- stroke="hsl(var(--chart-grid))"
- fontSize={11}
- tickLine={false}
- axisLine={false}
- />
- <YAxis
- stroke="hsl(var(--chart-grid))"
- fontSize={11}
- tickLine={false}
- axisLine={false}
- width={26}
- />
- </>
-);
-
-const meta = preview.meta({
- component: LineChartTimeSeries,
- tags: ["!dev"],
-});
-
-// ── V1 Β· Draw what was measured ──────────────────────────────────────────────
-export const Interpolation = meta.story({
- render: () => (
- <div className="flex flex-wrap gap-5 p-1">
- {(
- [
- ["Straight", "linear", "What we measured. The honest default."],
- ["Smooth", "monotone", "Invents values between points. Opt-in only."],
- [
- "Stepped",
- "stepAfter",
- "Holds until it changes. For state/counters.",
- ],
- ] as const
- ).map(([label, type, caption]) => (
- <ExampleCard key={type} label={label} caption={caption}>
- <ResponsiveContainer>
- <LineChart data={sparse} margin={{ top: 8, right: 8, bottom: 0 }}>
- {axes}
- <Line
- type={type}
- dataKey="y"
- stroke="hsl(var(--chart-1))"
- strokeWidth={2.5}
- dot={false}
- isAnimationActive={false}
- />
- </LineChart>
- </ResponsiveContainer>
- </ExampleCard>
- ))}
- </div>
- ),
-});
-
-// ── V2 Β· Missing is a gap, not a zero ────────────────────────────────────────
-const withHole: { x: string; y: number | null }[] = [
- { x: "1", y: 30 },
- { x: "2", y: 58 },
- { x: "3", y: null },
- { x: "4", y: null },
- { x: "5", y: 62 },
- { x: "6", y: 40 },
-];
-const zeroFilled = withHole.map((d) => ({ ...d, y: d.y ?? 0 }));
-
-export const NullHandling = meta.story({
- render: () => (
- <div className="flex flex-wrap gap-5 p-1">
- <ExampleCard
- label="Gap βœ“"
- caption="Null breaks the line. The truth: no data here."
- >
- <ResponsiveContainer>
- <LineChart data={withHole} margin={{ top: 8, right: 8, bottom: 0 }}>
- {axes}
- <Line
- type="linear"
- dataKey="y"
- stroke="hsl(var(--chart-1))"
- strokeWidth={2.5}
- dot={false}
- connectNulls={false}
- isAnimationActive={false}
- />
- </LineChart>
- </ResponsiveContainer>
- </ExampleCard>
- <ExampleCard
- label="Bridge"
- caption="Only when the series truly continues across the gap."
- >
- <ResponsiveContainer>
- <LineChart data={withHole} margin={{ top: 8, right: 8, bottom: 0 }}>
- {axes}
- <Line
- type="linear"
- dataKey="y"
- stroke="hsl(var(--chart-1))"
- strokeWidth={2.5}
- strokeDasharray="4 3"
- dot={false}
- connectNulls
- isAnimationActive={false}
- />
- </LineChart>
- </ResponsiveContainer>
- </ExampleCard>
- <ExampleCard
- label="Zero-fill βœ—"
- caption="Invents a measurement of 0. A lie for anything non-additive; only counts/sums may fill zeros."
- >
- <ResponsiveContainer>
- <LineChart data={zeroFilled} margin={{ top: 8, right: 8, bottom: 0 }}>
- {axes}
- <Line
- type="linear"
- dataKey="y"
- stroke="hsl(var(--destructive))"
- strokeWidth={2.5}
- dot={false}
- isAnimationActive={false}
- />
- </LineChart>
- </ResponsiveContainer>
- </ExampleCard>
- </div>
- ),
-});
-
-// ── V3 Β· Encode certainty with one grammar ───────────────────────────────────
-// `solid` = confirmed buckets; `faded` = still-aggregating tail (overlaps at the
-// boundary so the dotted+pale segment touches the solid one).
-const certainty = [
- { x: "1", solid: 32, faded: null as number | null },
- { x: "2", solid: 50, faded: null as number | null },
- { x: "3", solid: 44, faded: null as number | null },
- { x: "4", solid: 61, faded: 61 as number | null },
- { x: "5", solid: null as number | null, faded: 54 },
- { x: "6", solid: null as number | null, faded: 30 },
-];
-
-export const Certainty = meta.story({
- render: () => (
- <ExampleCard
- label="Confirmed vs. forming"
- caption="The still-aggregating tail is dotted + pale β€” present, but visibly less certain."
- >
- <ResponsiveContainer>
- <LineChart data={certainty} margin={{ top: 8, right: 8, bottom: 0 }}>
- {axes}
- <Line
- type="linear"
- dataKey="solid"
- stroke="hsl(var(--chart-1))"
- strokeWidth={2.5}
- dot={false}
- connectNulls={false}
- isAnimationActive={false}
- />
- <Line
- type="linear"
- dataKey="faded"
- stroke="hsl(var(--chart-1))"
- strokeWidth={2.5}
- strokeOpacity={0.45}
- strokeDasharray="3 3"
- dot={false}
- connectNulls={false}
- isAnimationActive={false}
- />
- </LineChart>
- </ResponsiveContainer>
- </ExampleCard>
- ),
-});
-
-// ── Reused production component (V4–V8) ───────────────────────────────────────
-const msFormatter: MetricFormatterFunction = (value, options) =>
- formatMetric(value, { ...options, unit: "millisecond" });
-
-const buildSeries = (
- series: { name: string; base: number; amp: number }[],
- days = 14,
-): DataPoint[] => {
- const points: DataPoint[] = [];
- for (let day = 0; day < days; day++) {
- const label = `2026-06-${String(day + 1).padStart(2, "0")}T00:00:00Z`;
- series.forEach(({ name, base, amp }, seed) => {
- const wave = 0.5 + 0.5 * Math.sin((day + seed * 1.7) / 2.3);
- const jitter = ((seed * 37 + day * 13) % 17) / 17;
- points.push({
- time_dimension: label,
- dimension: name,
- metric: Math.round(base + amp * wave + amp * 0.25 * jitter),
- });
- });
- }
- return points;
-};
-
-const fewSeries = buildSeries([
- { name: "gpt-4o", base: 800, amp: 600 },
- { name: "claude-3-5-sonnet", base: 1200, amp: 900 },
- { name: "gpt-4o-mini", base: 300, amp: 250 },
-]);
-
-// 30 series β†’ over the render cap (25) β†’ "Showing top 25 of 30 series".
-const manySeries = buildSeries(
- Array.from({ length: 30 }, (_, i) => ({
- name: `model-${String.fromCharCode(97 + (i % 26))}${Math.floor(i / 26)}`,
- base: 200 + i * 70,
- amp: 120 + (i % 5) * 60,
- })),
-);
-
-const ChartFrame = ({
- title,
- children,
-}: {
- title: string;
- children: React.ReactNode;
-}) => (
- <div className="bg-background rounded-md border p-3">
- <div className="mb-1 text-sm font-bold">{title}</div>
- <div className="h-[280px] w-full">{children}</div>
- </div>
-);
-
-// V4/V5 β€” hover snaps to a real sample; one synced crosshair, one tooltip.
-export const HoverTimeline = meta.story({
- render: () => (
- <div className="flex flex-col gap-3 p-1">
- <ChartFrame title="p95 latency by model">
- <LineChartTimeSeries
- data={fewSeries}
- syncId="charting-principles"
- legendPosition="below"
- showDataPointDots={false}
- metricFormatter={msFormatter}
- />
- </ChartFrame>
- <ChartFrame title="requests by model (same timeline)">
- <LineChartTimeSeries
- data={buildSeries([
- { name: "gpt-4o", base: 14_000, amp: 6_000 },
- { name: "claude-3-5-sonnet", base: 9_000, amp: 4_000 },
- { name: "gpt-4o-mini", base: 22_000, amp: 8_000 },
- ])}
- syncId="charting-principles"
- legendPosition="below"
- showDataPointDots={false}
- />
- </ChartFrame>
- </div>
- ),
-});
-
-// V6/V7 β€” quiet chrome, identity color, adaptive labels (production component).
-export const QuietChrome = meta.story({
- render: () => (
- <ChartFrame title="High data-ink: faint grid, no axis spine, muted labels">
- <LineChartTimeSeries
- data={fewSeries}
- legendPosition="below"
- showDataPointDots={false}
- metricFormatter={msFormatter}
- />
- </ChartFrame>
- ),
-});
-
-// V8 β€” bound the frame, not the data: top-N + an honest "N of M" note.
-export const BoundTheFrame = meta.story({
- render: () => (
- <ChartFrame title="30 series in, 25 drawn β€” and it says so">
- <LineChartTimeSeries
- data={manySeries}
- legendPosition="below"
- showDataPointDots={false}
- metricFormatter={msFormatter}
- />
- </ChartFrame>
- ),
-});
-
-// ── V2 in production Β· missing data through the real components ─────────────
-// These mirror the exact data shape the widget transforms hand the charts
-// (LFE-10694): a series' missing bucket is an ABSENT DataPoint, and a bucket
-// where nothing measured anything arrives as a dimension-less bucket MARKER
-// (`dimension: undefined, metric: null`) β€” what the query's gap-fill
-// placeholder rows become.
-
-type SeriesSpec = {
- name: string;
- /** One entry per bucket; `null` = this series measured nothing there. */
- values: (number | null)[];
-};
-
-/** Buckets are day labels 7/1..7/N; markers keep all-empty buckets on the axis. */
-const buildGappedData = (series: SeriesSpec[]): DataPoint[] => {
- const bucketCount = Math.max(...series.map((s) => s.values.length));
- const points: DataPoint[] = [];
- for (let bucket = 0; bucket < bucketCount; bucket++) {
- const label = `7/${bucket + 1}`;
- let bucketHasData = false;
- for (const { name, values } of series) {
- const value = values[bucket];
- if (value != null) {
- bucketHasData = true;
- points.push({ time_dimension: label, dimension: name, metric: value });
- }
- }
- if (!bucketHasData) {
- points.push({
- time_dimension: label,
- dimension: undefined,
- metric: null,
- });
- }
- }
- return points;
-};
-
-// One series, healthy on both sides of a 3-bucket hole (the classic lie shape).
-const midRangeGap: SeriesSpec[] = [
- {
- name: "gpt-4o",
- values: [820, 940, 760, null, null, null, 880, 810, 990, 870],
- },
-];
-
-// Multi-series where the gaps don't line up β€” every bucket has SOME data, so
-// only per-series cells are missing (no markers involved).
-const staggeredGapSeries: SeriesSpec[] = [
- {
- name: "gpt-4o",
- values: [820, 940, 760, null, null, 830, 880, 810, 990, 870],
- },
- {
- name: "claude-3-5-sonnet",
- values: [1450, null, null, 1380, 1520, 1490, null, null, null, 1400],
- },
- {
- name: "gpt-4o-mini",
- values: [310, 290, 340, 300, null, null, null, 280, 320, 330],
- },
- {
- name: "mistral-7b",
- values: [null, null, 540, 560, 520, null, 580, 610, null, null],
- },
-];
-
-// Isolated points: a lone first bucket, a mid-gap single, a lone last bucket,
-// and a series that is a segment plus one stranded value.
-const isolatedPointSeries: SeriesSpec[] = [
- {
- name: "first-bucket-only",
- values: [720, null, null, null, null, null, null, null, null, null],
- },
- {
- name: "single-mid-gap",
- values: [null, null, null, null, 1350, null, null, null, null, null],
- },
- {
- name: "last-bucket-only",
- values: [null, null, null, null, null, null, null, null, null, 980],
- },
- {
- name: "segment-plus-stranded",
- values: [420, 460, 440, null, null, null, null, 510, null, null],
- },
-];
-
-// Long empty stretch (buckets exist only as markers) between two active eras.
-const twoEras: SeriesSpec[] = [
- {
- name: "gpt-4o",
- values: [88, 96, 74, null, null, null, null, null, 91, 83],
- },
- {
- name: "claude-3-5-sonnet",
- values: [54, 61, null, null, null, null, null, null, 58, 66],
- },
-];
-
-export const GapVersusZero = meta.story({
- render: () => (
- <div className="flex flex-wrap gap-5 p-1">
- <ExampleCard
- tall
- label='missingValue="gap" (avg / percentiles)'
- caption="No latency exists on a bucket without generations β€” the line breaks. Fabricating a 0 would deflate the chart."
- >
- <LineChartTimeSeries
- data={buildGappedData(midRangeGap)}
- missingValue="gap"
- metricFormatter={msFormatter}
- />
- </ExampleCard>
- <ExampleCard
- tall
- label='missingValue="zero" (count / sum)'
- caption="Zero events on a bucket without data is the truth β€” the same shape stays continuous, touching 0."
- >
- <LineChartTimeSeries
- data={buildGappedData(midRangeGap)}
- missingValue="zero"
- />
- </ExampleCard>
- </div>
- ),
-});
-
-export const HonestVersusBridged = meta.story({
- render: () => (
- <div className="flex flex-wrap gap-5 p-1">
- <ExampleCard
- tall
- label="default (honest)"
- caption="Gap semantics: three empty buckets stay on the axis and the line breaks over them."
- >
- <LineChartTimeSeries
- data={buildGappedData(midRangeGap)}
- missingValue="gap"
- metricFormatter={msFormatter}
- />
- </ExampleCard>
- <ExampleCard
- tall
- label="connectNulls (the old default, now opt-in)"
- caption="The bridge draws values that were never measured. Reserved for series that semantically continue across a gap."
- >
- <LineChartTimeSeries
- data={buildGappedData(midRangeGap)}
- missingValue="gap"
- connectNulls
- metricFormatter={msFormatter}
- />
- </ExampleCard>
- </div>
- ),
-});
-
-export const IsolatedPoints = meta.story({
- render: () => (
- <div className="flex flex-wrap gap-5 p-1">
- <ExampleCard
- tall
- label="neighborless values"
- caption="A value with gaps on both sides spans no line segment β€” the dot is what keeps it visible (first bucket, mid-gap, last bucket, and a stranded point after a segment)."
- >
- <LineChartTimeSeries
- data={buildGappedData(isolatedPointSeries)}
- missingValue="gap"
- legendPosition="below"
- metricFormatter={msFormatter}
- />
- </ExampleCard>
- </div>
- ),
-});
-
-export const StaggeredSeriesGaps = meta.story({
- render: () => (
- <div className="flex flex-wrap gap-5 p-1">
- <ExampleCard
- tall
- label="per-series gaps, every bucket has some data"
- caption="Each series breaks over its own missing buckets while the others keep drawing β€” no series borrows another's shape."
- >
- <LineChartTimeSeries
- data={buildGappedData(staggeredGapSeries)}
- missingValue="gap"
- legendPosition="below"
- metricFormatter={msFormatter}
- />
- </ExampleCard>
- </div>
- ),
-});
-
-export const EmptyBucketsStayOnAxis = meta.story({
- render: () => (
- <div className="flex flex-wrap gap-5 p-1">
- <ExampleCard
- tall
- label="gap semantics"
- caption="Buckets 7/4–7/8 exist only as markers. The axis keeps them, so the empty era is visible instead of time compressing away."
- >
- <LineChartTimeSeries
- data={buildGappedData(twoEras)}
- missingValue="gap"
- legendPosition="below"
- />
- </ExampleCard>
- <ExampleCard
- tall
- label="zero semantics"
- caption="Same data as counts: the empty era reads as an honest flat 0, not as absence."
- >
- <LineChartTimeSeries
- data={buildGappedData(twoEras)}
- missingValue="zero"
- legendPosition="below"
- legendSummary="sum"
- />
- </ExampleCard>
- </div>
- ),
-});
-
-export const AreaGaps = meta.story({
- render: () => (
- <div className="flex flex-wrap gap-5 p-1">
- <ExampleCard
- tall
- label='area Β· missingValue="gap"'
- caption="The fill stops where the data stops; isolated values still get their dot."
- >
- <AreaChartTimeSeries
- data={buildGappedData(staggeredGapSeries)}
- missingValue="gap"
- metricFormatter={msFormatter}
- />
- </ExampleCard>
- <ExampleCard
- tall
- label='area Β· missingValue="zero"'
- caption="Additive semantics: the fill dips to 0 across empty buckets."
- >
- <AreaChartTimeSeries
- data={buildGappedData(twoEras)}
- missingValue="zero"
- />
- </ExampleCard>
- </div>
- ),
-});
diff --git a/web/src/features/widgets/chart-library/TimeAxisTick.clienttest.tsx b/web/src/features/widgets/chart-library/TimeAxisTick.clienttest.tsx
deleted file mode 100644
index 32becacd1e..0000000000
--- a/web/src/features/widgets/chart-library/TimeAxisTick.clienttest.tsx
+++ /dev/null
@@ -1,68 +0,0 @@
-import { describe, expect, it } from "vitest";
-import { renderToStaticMarkup } from "react-dom/server";
-import type { XAxisTickContentProps } from "recharts";
-import { timeAxisTick } from "./TimeAxisTick";
-
-const Tick = timeAxisTick((value) => `Aug ${value}`, "2");
-
-const tickPayload = (index: number, coordinate: number) => ({
- coordinate,
- value: String(index),
- index,
- offset: 0,
-});
-
-function renderTick(props: {
- x: number;
- y: number;
- index: number;
- visibleTicksCount: number;
- payload: ReturnType<typeof tickPayload>;
-}) {
- return renderToStaticMarkup(
- <svg>
- <Tick {...(props as XAxisTickContentProps)} />
- </svg>,
- );
-}
-
-describe("TimeAxisTick", () => {
- it("end-anchors the last data bucket so the date stays on-canvas", () => {
- const html = renderTick({
- x: 400,
- y: 0,
- index: 2,
- payload: tickPayload(2, 400),
- visibleTicksCount: 3,
- });
-
- expect(html).toContain('text-anchor="end"');
- expect(html).toContain("Aug 2");
- });
-
- it("keeps earlier ticks centered", () => {
- const html = renderTick({
- x: 200,
- y: 0,
- index: 1,
- payload: tickPayload(1, 200),
- visibleTicksCount: 3,
- });
-
- expect(html).toContain('text-anchor="middle"');
- expect(html).toContain("Aug 1");
- });
-
- it("keeps a thinned last-rendered tick centered when it is not the last bucket", () => {
- const html = renderTick({
- x: 320,
- y: 0,
- index: 5,
- payload: tickPayload(20, 320),
- visibleTicksCount: 6,
- });
-
- expect(html).toContain('text-anchor="middle"');
- expect(html).toContain("Aug 20");
- });
-});
diff --git a/web/src/features/widgets/chart-library/TimeAxisTick.tsx b/web/src/features/widgets/chart-library/TimeAxisTick.tsx
deleted file mode 100644
index eadecb6c44..0000000000
--- a/web/src/features/widgets/chart-library/TimeAxisTick.tsx
+++ /dev/null
@@ -1,60 +0,0 @@
-/* eslint-disable @repo/no-null-render */
-import type { ReactNode } from "react";
-import type { XAxisTickContentProps } from "recharts";
-
-type TimeAxisTickViewProps = {
- x?: number | string;
- y?: number | string;
- payload?: { value?: unknown };
-};
-
-function tickCoord(value: number | string | undefined): number | null {
- if (value == null) return null;
- const n = typeof value === "number" ? value : Number(value);
- return Number.isFinite(n) ? n : null;
-}
-
-/**
- * Temporal x-axis tick. A centered label on the last *bucket* clips at the
- * plot edge ("Aug 11" β†’ "Aug 1"). End-anchor only that last-bucket tick;
- * thinned ticks that are not the last bucket stay centered on their gridline.
- */
-function TimeAxisTick({
- x,
- y,
- payload,
- formatter,
- lastValue,
-}: TimeAxisTickViewProps & {
- formatter: (raw: unknown) => string;
- lastValue: unknown;
-}) {
- const tickX = tickCoord(x);
- const tickY = tickCoord(y);
- if (tickX == null || tickY == null) return null;
- const isLastBucket =
- lastValue != null && String(payload?.value) === String(lastValue);
- return (
- <text
- x={tickX}
- y={tickY}
- dy={8}
- textAnchor={isLastBucket ? "end" : "middle"}
- className="fill-muted-foreground/90"
- fontSize={12}
- >
- {formatter(payload?.value)}
- </text>
- );
-}
-
-export function timeAxisTick(
- formatter: (raw: unknown) => string,
- lastValue: unknown,
-): (props: XAxisTickContentProps) => ReactNode {
- return function TimeAxisTickRenderer(props: XAxisTickContentProps) {
- return (
- <TimeAxisTick {...props} formatter={formatter} lastValue={lastValue} />
- );
- };
-}