πͺ’ Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
chore(storybook): Simplify .mdx stories (#14711)
Ben Bachemfea632a11fbd
diff --git a/.agents/skills/storybook/SKILL.md b/.agents/skills/storybook/SKILL.mdindex 98b3731b5f..1398f796a8 100644--- a/.agents/skills/storybook/SKILL.md+++ b/.agents/skills/storybook/SKILL.md@@ -58,6 +58,15 @@ If the button also has a `variant: "primary" | "secondary"` prop, consider usingThese compositional stories **should not** contain Storybook play functions. They should also not allow the Storybook user to customize the predefined args, such as `size` and `variant`, via Storybook args. Having an arg for non-bound props, such as `text`, may be acceptable.+## Authoring MDX Docs++- Use `.mdx` for prose docs and guides that sit alongside stories.+- Keep `.mdx` files simple by default: standard markdown plus Storybook docs blocks such as `Meta` and `Canvas` are usually enough.+- Do not build bespoke page layouts in `.mdx` with exported inline-styled React components unless there is a strong reason.+- If docs need reusable typography, spacing, or docs-page chrome, add that once in Storybook preview/docs container setup rather than re-implementing it in a single `.mdx` file.+- Keep illustrative examples in `.stories.tsx`; keep narrative and explanation in `.mdx`.+- If an example needs a small wrapper in a story, keep it minimal and focused on presenting the example rather than recreating page design inside Storybook.+## Additional Information- We do not use MSW and are not planning to add it.diff --git a/web/.storybook/preview.tsx b/web/.storybook/preview.tsxindex c29f2a3982..bb85519615 100644--- a/web/.storybook/preview.tsx+++ b/web/.storybook/preview.tsx@@ -101,8 +101,56 @@ function ThemedDocsContainer({return (<DocsContainer context={context} theme={dark ? themes.dark : themes.light}><style>{`- .sbdocs-content { font-size: 16px; }- .sbdocs-content p, .sbdocs-content li { font-size: 1.0625rem; line-height: 1.7; }+ .sbdocs-wrapper {+ background: hsl(var(--background));+ color: hsl(var(--foreground));+ padding: 0;+ }++ .sbdocs-content {+ max-width: 56rem;+ padding: 3.5rem 2rem;+ color: hsl(var(--foreground));+ }++ .sbdocs-content a {+ color: hsl(var(--primary));+ }++ .sbdocs-content code {+ background: hsl(var(--muted));+ border-radius: 0.25rem;+ padding: 0.125rem 0.375rem;+ }++ .sbdocs-content pre {+ background: hsl(var(--muted));+ border: 1px solid hsl(var(--border));+ border-radius: 0.5rem;+ color: hsl(var(--foreground));+ }++ .sbdocs-content pre code {+ background: transparent;+ padding: 0;+ }++ .sbdocs-content blockquote {+ border-left: 3px solid hsl(var(--border));+ color: hsl(var(--muted-foreground));+ margin-left: 0;+ padding-left: 1rem;+ }++ .sbdocs-content hr {+ border-color: hsl(var(--border));+ }++ .sbdocs-content .sbdocs.sbdocs-preview {+ background: transparent;+ border: 1px solid hsl(var(--border));+ box-shadow: none;+ }`}</style>{children}</DocsContainer>diff --git a/web/src/components/design-system/OverlayLayers.mdx b/web/src/components/design-system/OverlayLayers.mdxnew file mode 100644index 0000000000..17e12284d8--- /dev/null+++ b/web/src/components/design-system/OverlayLayers.mdx@@ -0,0 +1,111 @@+import { Meta } from "@storybook/addon-docs/blocks";++<Meta title="Design System/Overlay Layers" parameters={{ layout: "fullscreen" }} />++# Overlay Layers++How every overlay in the app stacks: **by structure (DOM order), not by+z-index.**++## The problem this solves++Overlays such as dialogs, dropdowns, tooltips, toasts, and the in-app+assistant used to portal to `<body>` and compete for βwho is on topβ with+hand-picked z-index values. Those values kept escalating from `z-50` to `z-51`+to `z-60` to `z-[9999]`, and whoever picked the bigger one won until the next+overlay reset the race. Real bugs followed: toasts hidden behind the trace+peek, the search-bar error tooltip clipped, and the nav dropdown colliding with+the assistant window.++## The model++The whole app renders inside `#__next`, which is its own isolated stacking+context via `isolation: isolate`. That caps every z-index used inside the app,+so nothing in-app can paint over an overlay. The overlay layer containers are+declared once in `_document.tsx` as `<body>` siblings _after_ `#__next`, so+they paint on top purely by DOM order, where later means on top, and each is+itself an isolated stacking context.++**Ordering is the layer's job. Overlays carry no z-index.**++## The layers (low to high)++<table>+ <thead>+ <tr>+ <th>Layer</th>+ <th>Holds</th>+ <th>Why it sits here</th>+ </tr>+ </thead>+ <tbody>+ <tr>+ <td><code>agent</code></td>+ <td>the in-app assistant window</td>+ <td>+ persistent and draggable; floats above the page but below every+ transient overlay+ </td>+ </tr>+ <tr>+ <td><code>modal</code></td>+ <td>+ <code>Dialog</code>, <code>AlertDialog</code>, <code>Sheet</code>{" "}+ including the table peek, <code>Drawer</code>+ </td>+ <td>blocking surfaces, above the page and the assistant</td>+ </tr>+ <tr>+ <td><code>popover</code></td>+ <td>+ <code>Popover</code>, <code>DropdownMenu</code>, <code>Select</code>,{" "}+ <code>HoverCard</code>+ </td>+ <td>+ above modal, so a <code>Select</code> or <code>Popover</code> opened+ inside a dialog still renders on top+ </td>+ </tr>+ <tr>+ <td><code>tooltip</code></td>+ <td><code>Tooltip</code> and bespoke anchored tooltips</td>+ <td>hints stay above their trigger, even inside a modal</td>+ </tr>+ <tr>+ <td><code>toast</code></td>+ <td>Sonner toasts</td>+ <td>last, so they always sit above everything by order alone</td>+ </tr>+ </tbody>+</table>++`LAYER_ORDER` in `components/ui/layer.tsx` is the source of truth;+`_document.tsx` maps it to the containers.++## Pointer events++The layer containers are `pointer-events: none`, so the empty space around a+non-modal overlay, like the table peek, stays click-through to the app behind+it. Each portaled overlay opts itself back in with one global rule,+`[data-overlay-root] > [data-layer] > * { pointer-events: auto; }`, so every+overlay is interactive by construction, modal or not.++## How to use it++- **Radix or Vaul primitive:** route its `*.Portal` into a layer with+ `useLayerContainer(name)`. The `ui/*` wrappers such as `Dialog`,+ `DropdownMenu`, and `Select` already do this, so most code gets it for free.+- **Bespoke positioned content:** render it through `<Layer name="β¦">`.+- **Never** give an overlay a z-index to escape, and **never** let a+ `*.Portal` fall back to `<body>`.++## The guardrail++The `@repo/no-overlay-zindex` ESLint rule fails the build if a new overlay+reaches for a z-index escape, so the category of bug cannot return. Legit+in-app chrome such as sticky page headers, fixed top banners, and the bulk+action bar keeps its z-index because it lives inside `#__next` and never+competes with overlays.++Part of the design system. Storybook is, step by step, becoming the home for+these design-system decisions.diff --git a/web/src/components/design-system/OverlayLayers.stories.tsx b/web/src/components/design-system/OverlayLayers.stories.tsxdeleted file mode 100644index 2ac4e3f6d4..0000000000--- a/web/src/components/design-system/OverlayLayers.stories.tsx+++ /dev/null@@ -1,167 +0,0 @@-import React from "react";-import preview from "../../../.storybook/preview";--/**- * Design-system documentation: how every overlay in the app stacks β by- * structure (DOM order), not z-index. Rendered as a story (not standalone MDX,- * which this Storybook setup doesn't wire a docs renderer for).- */--const LAYERS: { name: string; holds: string; why: string }[] = [- {- name: "agent",- holds: "the in-app assistant window",- why: "persistent / draggable; floats above the page but BELOW every transient overlay",- },- {- name: "modal",- holds: "Dialog, AlertDialog, Sheet (incl. the table peek), Drawer",- why: "blocking surfaces, above the page and the assistant",- },- {- name: "popover",- holds: "Popover, DropdownMenu, Select, HoverCard",- why: "ABOVE modal, so a Select/Popover opened inside a Dialog still renders on top",- },- {- name: "tooltip",- holds: "Tooltip + bespoke anchored tooltips",- why: "hints stay above their trigger, even inside a modal",- },- {- name: "toast",- holds: "Sonner toasts",- why: "last, so they always sit above everything β by order alone, no z-index",- },-];--const Code = ({ children }: { children: React.ReactNode }) => (- <code className="bg-muted rounded px-1 py-0.5 font-mono text-[0.85em]">- {children}- </code>-);--const H = ({ children }: { children: React.ReactNode }) => (- <h2 className="text-foreground mt-8 mb-2 text-lg font-semibold">- {children}- </h2>-);--function OverlayLayersDoc() {- return (- <div className="text-foreground mx-auto max-w-3xl p-8 text-sm leading-relaxed">- <h1 className="text-2xl font-bold">Overlay layers</h1>- <p className="text-muted-foreground mt-1">- How every overlay in the app stacks β{" "}- <strong>by structure (DOM order), not by z-index.</strong>- </p>-- <H>The problem this solves</H>- <p>- Overlays β dialogs, dropdowns, tooltips, toasts, the in-app assistant β- each used to portal to <Code><body></Code> and compete for- “who’s on top” with hand-picked z-index numbers. Those- numbers kept escalating β <Code>z-50</Code> β <Code>z-51</Code> β{" "}- <Code>z-60</Code> β <Code>z-[9999]</Code> β and whoever picked the- bigger one won, until the next overlay reset the race. Real bugs- followed: toasts hidden behind the trace peek, the search-bar error- tooltip clipped, the nav dropdown colliding with the assistant window.- </p>-- <H>The model</H>- <p>- The whole app renders inside <Code>#__next</Code>, which is its own- isolated stacking context (<Code>isolation: isolate</Code>). That caps- every z-index used inside the app β nothing in-app can paint over an- overlay. The overlay layer containers are declared once in{" "}- <Code>_document.tsx</Code> as <Code><body></Code> siblings{" "}- <em>after</em> <Code>#__next</Code>, so they paint on top purely by DOM- order (later = on top), and each is itself an isolated stacking context.- </p>- <p className="mt-2 font-medium">- Ordering is the layer’s job. Overlays carry no z-index.- </p>-- <H>The layers (low β high)</H>- <table className="mt-2 w-full border-collapse text-left">- <thead>- <tr className="border-b">- <th className="py-2 pr-4 font-semibold">Layer</th>- <th className="py-2 pr-4 font-semibold">Holds</th>- <th className="py-2 font-semibold">Why it sits here</th>- </tr>- </thead>- <tbody>- {LAYERS.map((l) => (- <tr key={l.name} className="border-b align-top">- <td className="py-2 pr-4">- <Code>{l.name}</Code>- </td>- <td className="py-2 pr-4">{l.holds}</td>- <td className="text-muted-foreground py-2">{l.why}</td>- </tr>- ))}- </tbody>- </table>- <p className="text-muted-foreground mt-2">- <Code>LAYER_ORDER</Code> in <Code>components/ui/layer.tsx</Code> is the- source of truth; <Code>_document.tsx</Code> maps it to the containers.- </p>-- <H>Pointer events</H>- <p>- The layer containers are <Code>pointer-events: none</Code>, so the empty- space around a non-modal overlay (like the table peek) stays- click-through to the app behind it. Each portaled overlay opts itself- back in with a single global rule β{" "}- <Code>- [data-overlay-root] > [data-layer] > * { pointer-events:- auto }- </Code>{" "}- β so every overlay is interactive by construction, modal or not.- </p>-- <H>How to use it</H>- <ul className="ml-5 list-disc space-y-1">- <li>- <strong>Radix / Vaul primitive:</strong> route its{" "}- <Code>*.Portal</Code> into a layer with{" "}- <Code>useLayerContainer(name)</Code>. The <Code>ui/*</Code> wrappers- (Dialog, DropdownMenu, Select, β¦) already do this, so most code gets- it for free.- </li>- <li>- <strong>Bespoke positioned content:</strong> render it through{" "}- <Code><Layer name="β¦"></Code>.- </li>- <li>- <strong>Never</strong> give an overlay a z-index to- “escape”, and <strong>never</strong> let a{" "}- <Code>*.Portal</Code> fall back to <Code><body></Code>.- </li>- </ul>-- <H>The guardrail</H>- <p>- The <Code>@repo/no-overlay-zindex</Code> ESLint rule fails the build if- a new overlay reaches for a z-index escape β so the category of bug- can’t return. Legit in-app chrome (sticky page headers, fixed top- banners, the bulk-action bar) keeps its z-index: it lives inside{" "}- <Code>#__next</Code> and never competes with overlays.- </p>-- <p className="text-muted-foreground mt-8 border-t pt-4 text-xs">- Part of the design system. Storybook is, step by step, becoming the home- for these design-system decisions.- </p>- </div>- );-}--const meta = preview.meta({- title: "Design System/Overlay Layers",- component: OverlayLayersDoc,- parameters: { layout: "fullscreen" },-});--export const Overview = meta.story({});diff --git a/web/src/features/widgets/chart-library/ChartingPrinciples.mdx b/web/src/features/widgets/chart-library/ChartingPrinciples.mdxindex 683237b5f9..161b2afe97 100644--- a/web/src/features/widgets/chart-library/ChartingPrinciples.mdx+++ b/web/src/features/widgets/chart-library/ChartingPrinciples.mdx@@ -3,317 +3,92 @@ import * as Principles from "./ChartingPrinciples.stories";<Meta title="Design System/Charts/Principles" />-export const RED = "#E4002B";-export const FG = "hsl(var(--foreground))";-export const BG = "hsl(var(--background))";-export const MUTED = "hsl(var(--muted-foreground))";-export const BORDER = "hsl(var(--border))";-// RED is the one fixed accent (reads on both themes); FG/BG/MUTED/BORDER track-// the app theme. The bold slabs (hero, principle numbers) stay a fixed-// ink/paper in BOTH themes β flipping them to a light block via the theme vars-// looked washed-out and wrong in dark.-export const INK = "#0B0B0B";-export const PAPER = "#F3F1EA";+# Charting Principles-export const Page = ({ children }) => (- <div- style={{- background: BG,- color: FG,- padding: "56px clamp(24px, 6vw, 88px)",- fontFamily:- "ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",- }}- >- {/* Storybook's docs theme paints the whole page (and every example card)- light, and can't follow our per-toggle theme. Pull the page background,- the side padding, and the example-card chrome onto the app's themed- vars so the article is fully dark in dark mode β no white frame, no- white padding. */}- <style>{`- .sbdocs-wrapper{background:hsl(var(--background)) !important;padding:0 !important;}- .sbdocs-content{max-width:none !important;padding:0 !important;}- .sbdocs.sbdocs-preview{background:transparent !important;border:0 !important;box-shadow:none !important;}- `}</style>- <div style={{ maxWidth: 880, margin: "0 auto" }}>{children}</div>- </div>-);+The data carries the weight. The frame stays quiet.-export const Hero = () => (- <div- style={{- position: "relative",- overflow: "hidden",- background: INK,- color: PAPER,- border: `1px solid ${BORDER}`,- padding: "72px 48px 64px",- marginBottom: 64,- }}- >- <div- style={{- position: "absolute",- right: -60,- top: -60,- width: 280,- height: 280,- background: RED,- transform: "rotate(18deg)",- }}- />- <div style={{ position: "relative" }}>- <div style={{ fontSize: 12, fontWeight: 800, letterSpacing: "0.4em" }}>- LANGFUSE Β· CHART LIBRARY- </div>- <h1- style={{- color: PAPER,- fontSize: "clamp(56px, 11vw, 104px)",- lineHeight: 0.88,- fontWeight: 900,- letterSpacing: "-0.045em",- margin: "16px 0 0",- }}- >- DRAW- <br />- ANYTHING.- </h1>- <p- style={{- color: PAPER,- fontSize: 22,- fontWeight: 600,- maxWidth: 540,- marginTop: 24,- opacity: 0.85,- }}- >- Eight moves for rendering any data β clean or noisy, sparse or- overloaded β legibly, every time.- </p>- </div>- </div>-);--export const Lede = () => (- <div- style={{- borderLeft: `10px solid ${RED}`,- paddingLeft: 24,- margin: "0 0 56px",- fontSize: "clamp(24px, 4vw, 34px)",- fontWeight: 900,- lineHeight: 1.12,- letterSpacing: "-0.02em",- maxWidth: 680,- }}- >- The data carries the weight.- <br />- The frame stays quiet.- </div>-);+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.-export const Slab = ({ n, t, lead, children }) => (- <section style={{ margin: "0 0 24px" }}>- <div style={{ display: "flex", gap: 22, alignItems: "flex-start" }}>- <div- style={{- flex: "0 0 auto",- width: 60,- height: 60,- background: INK,- color: PAPER,- border: `1px solid ${BORDER}`,- fontSize: 28,- fontWeight: 900,- display: "flex",- alignItems: "center",- justifyContent: "center",- }}- >- {n}- </div>- <div style={{ paddingTop: 2 }}>- <h2- style={{- fontSize: "clamp(22px, 3.4vw, 30px)",- fontWeight: 900,- letterSpacing: "-0.02em",- textTransform: "uppercase",- margin: "0 0 8px",- lineHeight: 1.02,- }}- >- {t}- </h2>- {lead && (- <p- style={{- fontSize: 18,- fontWeight: 700,- margin: "0 0 6px",- color: RED,- }}- >- {lead}- </p>- )}- <div style={{ fontSize: 16, lineHeight: 1.55, maxWidth: 660 }}>- {children}- </div>- </div>- </div>- </section>-);+## 1. Draw what was measured-export const Plate = ({ children }) => (- <div style={{ margin: "20px 0 44px", paddingLeft: 82 }}>{children}</div>-);+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.-export const Rule = () => (- <div style={{ height: 6, background: FG, margin: "8px 0 40px" }} />-);+<Canvas of={Principles.Interpolation} sourceState="none" />-<Page>+## 2. Missing is a gap, not a zero-<Hero />+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.-<Lede />+<Canvas of={Principles.NullHandling} sourceState="none" />-A chart here is not a picture we compose by hand. It is the last step of a-pipeline β **data β prepare β visualise β pixels** β and 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. They-are deliberately absolute. Read them as commandments, argue with them in the-preparer, never in the chart component.+## 3. Show certainty in the ink-<Rule />+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.-<Slab n="1" t="Draw what was measured" lead="No invented shape between points.">- Straight segments are the honest default β they claim only the points we have.- A smooth curve <strong>invents values that were never sampled</strong>; reach- for it only when you mean to. Stepped lines are for data that holds until it- changes (states, counters). The line is a record, not a decoration.-</Slab>+<Canvas of={Principles.Certainty} sourceState="none" />-<Plate>- <Canvas of={Principles.Interpolation} sourceState="none" />-</Plate>+## 4. Hover is a timeline, not a panel-<Slab- n="2"- t="Missing is a gap, not a zero"- lead="A hole in the data is the truth."->- A null breaks the line. Substituting <strong>0</strong> to "fill" the hole- manufactures a measurement that never happened β the single most common way a- chart lies. Bridge a gap only when the series genuinely continues across it;- break the line when a gap runs longer than the sampling cadence. Zero is a- value, not a synonym for absence.-</Slab>+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.-<Plate>- <Canvas of={Principles.NullHandling} sourceState="none" />-</Plate>+<Canvas of={Principles.HoverTimeline} sourceState="none" />-<Slab- n="3"- t="Show certainty in the ink"- lead="One grammar for less-sure data."->- A still-aggregating final bucket and a previous-period comparison are real,- but they are <strong>less certain</strong> than confirmed history. Don't drop- them and don't draw them as solid fact β render them dotted and paled. One- treatment, used everywhere, so a reader learns the grammar once and trusts it.-</Slab>+## 5. Color is identity-<Plate>- <Canvas of={Principles.Certainty} sourceState="none" />-</Plate>+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.-<Slab- n="4"- t="Hover is a timeline, not a panel"- lead="Snap to real samples; share the crosshair."->- The cursor between two points must never conjure a reading that isn't 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 <strong>one</strong> vertical marker; only the- chart under the cursor opens a tooltip. Emphasis lives in the tooltip and the- legend β the canvas stays calm.-</Slab>+## 6. Trust the scale-<Plate>- <Canvas of={Principles.HoverTimeline} sourceState="none" />-</Plate>+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.-<Slab n="5" t="Color is identity" lead="Assign once. Read it back.">- 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.-</Slab>+<Canvas of={Principles.QuietChrome} sourceState="none" />-<Slab n="6" t="Trust the scale" lead="Type-driven, adaptive formatting.">- Numbers, durations, bytes, percentages, currency, dates β each formats by its- kind and by the magnitude the scale chose. One unit per axis. Tick precision- follows the scale; tooltip precision is capped for reading; digits are tabular- so they never jitter. Don't out-clever the axis engine β format the spacing it- gives you.-</Slab>+## 7. Spend ink on data-<Plate>- <Canvas of={Principles.QuietChrome} sourceState="none" />-</Plate>+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.-<Slab n="7" t="Spend ink on data" lead="Quiet the frame.">- Faint horizontal gridlines, no axis spine, muted labels, no data-point dots by- default, fills barely there, 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.-</Slab>+## 8. Bound the frame, not the data-<Slab n="8" t="Bound the frame, not the data" lead="Top-N, and say so.">- Two hundred series is not a chart, it is a wall. Draw a legible top-N, rolled- by magnitude, and state the truth in the open β{" "}- <em>βshowing top 25 of 487.β</em>- Bound the legend, bound the density upstream (about one point per pixel).- Never buy legibility by silently throwing data away where no one can see you- do it.-</Slab>+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.-<Plate>- <Canvas of={Principles.BoundTheFrame} sourceState="none" />-</Plate>+<Canvas of={Principles.BoundTheFrame} sourceState="none" />-<Rule />+## Summary-<div- style={{- background: RED,- color: "#fff",- padding: "40px 44px",- fontSize: "clamp(22px, 4vw, 32px)",- fontWeight: 900,- lineHeight: 1.15,- letterSpacing: "-0.02em",- }}->- One adaptable pipeline. No special cases.- <br />- Teach the preparer a new shape β never the component a new exception.-</div>+One adaptable pipeline. No special cases.-<p style={{ fontSize: 14, color: MUTED, marginTop: 28 }}>- The full architecture and the one-way{" "}- <strong>data β prepare β visualise</strong> rule live in{" "}- <code>web/src/features/widgets/chart-library/ARCHITECTURE.md</code>. For how- overlays escape the chart frame, see the layer system in{" "}- <code>web/src/components/ui/layer.tsx</code> (Design System β Overlay Layers).-</p>+Teach the preparer a new shape, never the component a new exception.-</Page>+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/components/ui/layer.tsx`.diff --git a/web/src/features/widgets/chart-library/ChartingPrinciples.stories.tsx b/web/src/features/widgets/chart-library/ChartingPrinciples.stories.tsxindex eed5801057..091d45f599 100644--- a/web/src/features/widgets/chart-library/ChartingPrinciples.stories.tsx+++ b/web/src/features/widgets/chart-library/ChartingPrinciples.stories.tsx@@ -30,7 +30,7 @@ const sparse = [{ x: "6", y: 68 },];-const Mini = ({+const ExampleCard = ({label,caption,children,@@ -39,19 +39,15 @@ const Mini = ({caption: string;children: React.ReactNode;}) => (- <div className="flex flex-col gap-1">+ <div className="flex min-w-[210px] flex-1 flex-col gap-1"><div className="text-xs font-bold tracking-wide uppercase">{label}</div>- <div className="bg-background h-[150px] w-[210px] rounded-md border p-2">+ <div className="bg-background h-[150px] w-full rounded-md border p-2">{children}</div>- <div className="text-muted-foreground w-[210px] text-xs">{caption}</div>+ <div className="text-muted-foreground w-full text-xs">{caption}</div></div>);-const Row = ({ children }: { children: React.ReactNode }) => (- <div className="flex flex-wrap gap-5">{children}</div>-);-const axes = (<><CartesianGrid stroke="hsl(var(--chart-grid))" vertical={false} />@@ -75,19 +71,12 @@ const axes = (const meta = preview.meta({title: "Design System/Charts/Illustrations",component: LineChartTimeSeries,- decorators: [- (Story) => (- <div className="max-w-[720px] p-1">- <Story />- </div>- ),- ],});// ββ V1 Β· Draw what was measured ββββββββββββββββββββββββββββββββββββββββββββββexport const Interpolation = meta.story({render: () => (- <Row>+ <div className="flex flex-wrap gap-5 p-1">{([["Straight", "linear", "What we measured. The honest default."],@@ -99,7 +88,7 @@ export const Interpolation = meta.story({],] as const).map(([label, type, caption]) => (- <Mini key={type} label={label} caption={caption}>+ <ExampleCard key={type} label={label} caption={caption}><ResponsiveContainer><LineChart data={sparse} margin={{ top: 8, right: 8, bottom: 0 }}>{axes}@@ -113,9 +102,9 @@ export const Interpolation = meta.story({/></LineChart></ResponsiveContainer>- </Mini>+ </ExampleCard>))}- </Row>+ </div>),});@@ -132,8 +121,8 @@ const zeroFilled = withHole.map((d) => ({ ...d, y: d.y ?? 0 }));export const NullHandling = meta.story({render: () => (- <Row>- <Mini+ <div className="flex flex-wrap gap-5 p-1">+ <ExampleCardlabel="Gap β"caption="Null breaks the line. The truth: no data here.">@@ -151,8 +140,8 @@ export const NullHandling = meta.story({/></LineChart></ResponsiveContainer>- </Mini>- <Mini+ </ExampleCard>+ <ExampleCardlabel="Bridge"caption="Only when the series truly continues across the gap.">@@ -171,8 +160,8 @@ export const NullHandling = meta.story({/></LineChart></ResponsiveContainer>- </Mini>- <Mini+ </ExampleCard>+ <ExampleCardlabel="Zero-fill β"caption="Invents a measurement of 0. A lie, unless stacking demands it.">@@ -189,8 +178,8 @@ export const NullHandling = meta.story({/></LineChart></ResponsiveContainer>- </Mini>- </Row>+ </ExampleCard>+ </div>),});@@ -208,7 +197,7 @@ const certainty = [export const Certainty = meta.story({render: () => (- <Mini+ <ExampleCardlabel="Confirmed vs. forming"caption="The still-aggregating tail is dotted + pale β present, but visibly less certain.">@@ -237,7 +226,7 @@ export const Certainty = meta.story({/></LineChart></ResponsiveContainer>- </Mini>+ </ExampleCard>),});@@ -280,14 +269,14 @@ const manySeries = buildSeries(})),);-const Frame = ({+const ChartFrame = ({title,children,}: {title: string;children: React.ReactNode;}) => (- <div className="bg-background w-[680px] rounded-md border p-3">+ <div className="bg-background rounded-md border p-3"><div className="mb-1 text-sm font-medium">{title}</div><div className="h-[280px] w-full">{children}</div></div>@@ -296,8 +285,8 @@ const Frame = ({// 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">- <Frame title="p95 latency by model">+ <div className="flex flex-col gap-3 p-1">+ <ChartFrame title="p95 latency by model"><LineChartTimeSeriesdata={fewSeries}syncId="charting-principles"@@ -305,8 +294,8 @@ export const HoverTimeline = meta.story({showDataPointDots={false}metricFormatter={msFormatter}/>- </Frame>- <Frame title="requests by model (same timeline)">+ </ChartFrame>+ <ChartFrame title="requests by model (same timeline)"><LineChartTimeSeriesdata={buildSeries([{ name: "gpt-4o", base: 14_000, amp: 6_000 },@@ -317,7 +306,7 @@ export const HoverTimeline = meta.story({legendPosition="above"showDataPointDots={false}/>- </Frame>+ </ChartFrame></div>),});@@ -325,27 +314,27 @@ export const HoverTimeline = meta.story({// V6/V7 β quiet chrome, identity color, adaptive labels (production component).export const QuietChrome = meta.story({render: () => (- <Frame title="High data-ink: faint grid, no axis spine, muted labels">+ <ChartFrame title="High data-ink: faint grid, no axis spine, muted labels"><LineChartTimeSeriesdata={fewSeries}legendPosition="above"showDataPointDots={false}metricFormatter={msFormatter}/>- </Frame>+ </ChartFrame>),});// V8 β bound the frame, not the data: top-N + an honest "N of M" note.export const BoundTheFrame = meta.story({render: () => (- <Frame title="30 series in, 25 drawn β and it says so">+ <ChartFrame title="30 series in, 25 drawn β and it says so"><LineChartTimeSeriesdata={manySeries}legendPosition="above"showDataPointDots={false}metricFormatter={msFormatter}/>- </Frame>+ </ChartFrame>),});