Skip to content

Editorial diagram design for Claude Code, Codex, GitHub Copilot, Cursor, Factory Droid, Qoder, and Pi. 45 diagram types. Self-contained HTML + SVG. No shadows. No Mermaid slop.

feat(scatter): add box plot variant for five-number summaries (#435)

Matt Van Horn7bf9445418ff
diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.json
index e74fe14..da30c6c 100644
--- a/.codex-plugin/plugin.json
+++ b/.codex-plugin/plugin.json
@@ -26,7 +26,7 @@
"interface": {
"displayName": "Diagram Design",
"shortDescription": "Create editorial diagrams",
- "longDescription": "Diagram Design turns a description of your system, process, or data into an editorial diagram that matches your brand. Editorial diagrams your designer won't hate. No Figma. No generic rounded boxes. No 30-minute color-picking sessions.\n\nDescribe what you need and get a self-contained HTML file with inline SVG that opens in any browser and exports to SVG or PNG. Point it at your website once and it reads your colors and fonts, so every diagram looks like the rest of your site. It also redraws draw.io, Mermaid, and Excalidraw files at the size and level of detail you choose.\n\nEvery node earns its place. The accent color is reserved for the one or two things the reader should look at first.\n\n45 diagram types: architecture, architecture delta, IT current-state, flowchart, sequence, state machine, ER/data model, timeline, swimlane, quadrant, radar/spider, polar chart (polar/radial lollipop), loop/flywheel, nested, tree, org chart, layer stack, exploded axonometric, axonometric site/floor plan, Venn, pyramid/funnel, treemap and marimekko, heatmap, bar and dumbbell, waterfall, line (slopegraph, ridgeline, streamgraph, bump), Gantt and scatter charts (bubble, beeswarm), high-level, process, medallion, data flow, DP integration, DP security matrix, Sankey, fishbone, Wardley map, kanban, user journey, service blueprint, deployment, dependency graph, UML class, story map, and database schema. Plus lifecycle phase maps, block decomposition trees, semantic patterns, callouts, accessible motion, and sketchy hand-drawn styling.",
+ "longDescription": "Diagram Design turns a description of your system, process, or data into an editorial diagram that matches your brand. Editorial diagrams your designer won't hate. No Figma. No generic rounded boxes. No 30-minute color-picking sessions.\n\nDescribe what you need and get a self-contained HTML file with inline SVG that opens in any browser and exports to SVG or PNG. Point it at your website once and it reads your colors and fonts, so every diagram looks like the rest of your site. It also redraws draw.io, Mermaid, and Excalidraw files at the size and level of detail you choose.\n\nEvery node earns its place. The accent color is reserved for the one or two things the reader should look at first.\n\n45 diagram types: architecture, architecture delta, IT current-state, flowchart, sequence, state machine, ER/data model, timeline, swimlane, quadrant, radar/spider, polar chart (polar/radial lollipop), loop/flywheel, nested, tree, org chart, layer stack, exploded axonometric, axonometric site/floor plan, Venn, pyramid/funnel, treemap and marimekko, heatmap, bar and dumbbell, waterfall, line (slopegraph, ridgeline, streamgraph, bump), Gantt and scatter charts (bubble, beeswarm, box plot), high-level, process, medallion, data flow, DP integration, DP security matrix, Sankey, fishbone, Wardley map, kanban, user journey, service blueprint, deployment, dependency graph, UML class, story map, and database schema. Plus lifecycle phase maps, block decomposition trees, semantic patterns, callouts, accessible motion, and sketchy hand-drawn styling.",
"developerName": "LittleMight",
"category": "Creativity",
"capabilities": [
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 744981c..cf90999 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -429,6 +429,16 @@ jobs:
id: beeswarm_tests
run: python scripts/test-verify-beeswarm.py
+ - name: Verify box-plot five-number geometry
+ if: always()
+ id: box_plot
+ run: python scripts/verify-box-plot.py --all
+
+ - name: Verify box-plot checker
+ if: always()
+ id: box_plot_tests
+ run: python scripts/test-verify-box-plot.py
+
- name: Verify architecture delta snapshots and ledger
if: always()
id: architecture_delta
@@ -609,6 +619,8 @@ jobs:
echo "| Bump Checker | ${{ steps.bump_tests.outcome == 'success' && '✅ Passed' || (steps.bump_tests.outcome == 'skipped' && '⏭️ Skipped' || '❌ Failed') }} |" >> "$GITHUB_STEP_SUMMARY"
echo "| Beeswarm Positions & Packing | ${{ steps.beeswarm.outcome == 'success' && '✅ Passed' || (steps.beeswarm.outcome == 'skipped' && '⏭️ Skipped' || '❌ Failed') }} |" >> "$GITHUB_STEP_SUMMARY"
echo "| Beeswarm Checker | ${{ steps.beeswarm_tests.outcome == 'success' && '✅ Passed' || (steps.beeswarm_tests.outcome == 'skipped' && '⏭️ Skipped' || '❌ Failed') }} |" >> "$GITHUB_STEP_SUMMARY"
+ echo "| Box-Plot Five-Number Geometry | ${{ steps.box_plot.outcome == 'success' && '✅ Passed' || (steps.box_plot.outcome == 'skipped' && '⏭️ Skipped' || '❌ Failed') }} |" >> "$GITHUB_STEP_SUMMARY"
+ echo "| Box-Plot Checker | ${{ steps.box_plot_tests.outcome == 'success' && '✅ Passed' || (steps.box_plot_tests.outcome == 'skipped' && '⏭️ Skipped' || '❌ Failed') }} |" >> "$GITHUB_STEP_SUMMARY"
echo "| Architecture Delta Snapshots & Ledger | ${{ steps.architecture_delta.outcome == 'success' && '✅ Passed' || (steps.architecture_delta.outcome == 'skipped' && '⏭️ Skipped' || '❌ Failed') }} |" >> "$GITHUB_STEP_SUMMARY"
echo "| Architecture Delta Checker | ${{ steps.architecture_delta_tests.outcome == 'success' && '✅ Passed' || (steps.architecture_delta_tests.outcome == 'skipped' && '⏭️ Skipped' || '❌ Failed') }} |" >> "$GITHUB_STEP_SUMMARY"
echo "| Architecture Containment Scopes | ${{ steps.architecture_containment.outcome == 'success' && '✅ Passed' || (steps.architecture_containment.outcome == 'skipped' && '⏭️ Skipped' || '❌ Failed') }} |" >> "$GITHUB_STEP_SUMMARY"
diff --git a/.maintainer-policy.json b/.maintainer-policy.json
index 2ba6ba1..5bab06b 100644
--- a/.maintainer-policy.json
+++ b/.maintainer-policy.json
@@ -115,6 +115,8 @@
"python3 scripts/test-verify-bump.py",
"python3 scripts/verify-beeswarm.py --all",
"python3 scripts/test-verify-beeswarm.py",
+ "python3 scripts/verify-box-plot.py --all",
+ "python3 scripts/test-verify-box-plot.py",
"python3 scripts/verify-skin-polarity.py --all",
"python3 scripts/test-verify-skin-polarity.py",
"python3 scripts/test-export-wait.py",
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index dcfb174..ac95123 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -102,6 +102,8 @@ Every validation gate below must pass before a PR is ready. They also run automa
| Bump checker behaves (pass + adversarial cases) | `python3 scripts/test-verify-bump.py` |
| Beeswarm dots sit exactly at their values on one shared scale with no overprint | `python3 scripts/verify-beeswarm.py --all` |
| Beeswarm checker behaves (pass + adversarial cases) | `python3 scripts/test-verify-beeswarm.py` |
+| Box-plot five-number summaries sit on one shared scale, ordered, with outliers outside the whiskers | `python3 scripts/verify-box-plot.py --all` |
+| Box-plot checker behaves (pass + adversarial cases) | `python3 scripts/test-verify-box-plot.py` |
| Every directional tone claim matches the ramp it describes, on every skin | `python3 scripts/verify-skin-polarity.py --all` |
| Skin-polarity checker behaves (pass + adversarial cases) | `python3 scripts/test-verify-skin-polarity.py` |
| Generated icon assets are up to date (`icons.html`, `primitive-icons.md`) | `python3 scripts/build-icons.py` then `git diff --exit-code` on the two generated files |
@@ -207,6 +209,8 @@ python3 scripts/test-plugin-package.py \
&& python3 scripts/test-verify-bump.py \
&& python3 scripts/verify-beeswarm.py --all \
&& python3 scripts/test-verify-beeswarm.py \
+ && python3 scripts/verify-box-plot.py --all \
+ && python3 scripts/test-verify-box-plot.py \
&& python3 scripts/verify-skin-polarity.py --all \
&& python3 scripts/test-verify-skin-polarity.py \
&& python3 scripts/test-export-wait.py
@@ -226,6 +230,7 @@ python3 scripts/test-plugin-package.py \
- **`verify-bubble.py`:** a bubble is drawn off the shared axis scale its peers describe, its radius disagrees with the one area constant (`r = K·√size`), a second bubble wears the accent, an overlapping smaller bubble is painted under a larger one, or a bound label/tick disagrees with the mark it names. Fix the geometry, never the binding — and never nudge a bubble to open up space, because crowded bubbles mean the values really are close.
- **`verify-bump.py`:** a vertex sits off the rank grid the figure itself declares, a snapshot's ranks are not a permutation of 1..N, a segment curves or arrives by a relative command, or an endpoint label is missing a coordinate, drawn inboard of the end it names, or off the gutter its peers share. Fix the geometry or the declaration, never the label — and never nudge a vertex off its row to dodge a label collision, because a rank between two ranks is not a rank.
- **`verify-beeswarm.py`:** a dot is drawn off the shared value scale its peers describe, two dots declaring one value sit at two positions, a pair overprints instead of dodging, a second radius or a second non-focal fill appears, a second dot wears the accent, two dots share a `data-name` (or one is empty), anything positions a mark from CSS (`transform`, `translate`/`rotate`/`scale`, a geometry property, a motion path) by any carrier — attribute, inline `style`, or `<style>` rule, or a bound label/tick disagrees with the mark it names. Fix the geometry, never the binding — and never move a dot along the value axis to open up space, because crowding is data and the dodge is the only honest resolution.
+- **`verify-box-plot.py`:** a box, median, whisker or outlier is drawn off the shared value scale its peers describe, the five-number order is broken, an outlier sits inside the whiskers or the Tukey fences, a category label names the wrong series, a second series wears the accent, two series share a `data-name`, anything positions a mark from CSS, or a bound tick disagrees with the mark it names. Fix the geometry, never the binding — and never move a box along the value axis to open up space, because crowded boxes mean the summaries really are close.
- **`verify-skin-polarity.py`:** a legend key or caption names the ramp's direction by lightness (`darker is larger`) in a file whose ramp composites the other way. `ink` is a role, not a colour — it resolves near-black on light paper and near-white on dark — so one set of opacities runs darker as it strengthens in the light skin and lighter in the dark one. Name the direction by contrast against the paper (`stronger contrast is larger`), which survives the skin swap, and ship the same sentence in every variant; never invert the word for one file. The gate also fails closed on a claim it cannot substantiate — no resolvable paper colour, fewer than three rank-bearing ramp members, or a ramp that is not strictly ordered — and on wording it cannot parse: a tone word within six words of a magnitude word that no supported sentence form binds. Rephrase that as `<tone> <is|means|represents> <magnitude>` (`stronger contrast is larger`), because a claim the gate cannot read is a claim nothing checks.
- **`verify-geometry.py`:** a label mask overlaps a node declared later in the document, so the node fill clips the label at render time. Move the label to a free segment of its connector — keep the 6–10px gap from the stroke required by SKILL.md §6, and do not shrink the mask to sneak under the check. It also fails an arrowed connector with a diagonal straight segment, a segment lying on a node's border, an endpoint within 8px of a node corner, a port closer to another on the same edge than rule 4 allows (12px, or 8px on an edge under 48px), a straight run stacked on another connector, or path data it cannot parse. Reroute the connector so it leaves each box perpendicular to the edge it starts on, from its own port; do not drop the marker or the node stroke to get past the check.
- **`verify-architecture-delta.py`:** a stable ID, snapshot membership, status, signature, position, endpoint, or ledger target disagrees with the declared migration. Follow `type-architecture-delta.md`: record every changed object in the center ledger, retain unchanged positions on matching grids, and distinguish CHANGED, MOVED, and REWIRED by what actually differs. Fix the diagram and metadata together; never suppress the ledger entry to hide an unaccounted change.
diff --git a/README.md b/README.md
index 8e96c92..2660309 100644
--- a/README.md
+++ b/README.md
@@ -325,7 +325,7 @@ The model already understood the content. What it was missing was taste, so I wr
</tr>
</table>
-Several types have named variants that share their reference: Line covers slopegraph, ridgeline, streamgraph and bump; Scatter covers bubble and beeswarm; Treemap covers marimekko.
+Several types have named variants that share their reference: Line covers slopegraph, ridgeline, streamgraph and bump; Scatter covers bubble, beeswarm and box plot; Treemap covers marimekko.
Architecture can nest administrative bands and traffic boxes in one snapshot when the hierarchy itself is the claim: dashed rx=4 bands for billing and permissions, solid rx=8 boxes for networks, and managed services outside every subnet. See the [containment example](skills/diagram-design/assets/example-architecture-containment.html) and [type-architecture.md](skills/diagram-design/references/type-architecture.md).
diff --git a/docs/pr-previews/box-plot/box-plot-dark.png b/docs/pr-previews/box-plot/box-plot-dark.png
new file mode 100644
index 0000000..b4074c0
Binary files /dev/null and b/docs/pr-previews/box-plot/box-plot-dark.png differ
diff --git a/docs/pr-previews/box-plot/box-plot-full.png b/docs/pr-previews/box-plot/box-plot-full.png
new file mode 100644
index 0000000..b9939c6
Binary files /dev/null and b/docs/pr-previews/box-plot/box-plot-full.png differ
diff --git a/docs/pr-previews/box-plot/box-plot-light.png b/docs/pr-previews/box-plot/box-plot-light.png
new file mode 100644
index 0000000..6a32ed1
Binary files /dev/null and b/docs/pr-previews/box-plot/box-plot-light.png differ
diff --git a/scripts/test-maintainer-policy.py b/scripts/test-maintainer-policy.py
index ebc7fdc..2091046 100644
--- a/scripts/test-maintainer-policy.py
+++ b/scripts/test-maintainer-policy.py
@@ -83,6 +83,8 @@ REQUIRED_COMMANDS = {
"python3 scripts/test-verify-marimekko.py",
"python3 scripts/verify-beeswarm.py --all",
"python3 scripts/test-verify-beeswarm.py",
+ "python3 scripts/verify-box-plot.py --all",
+ "python3 scripts/test-verify-box-plot.py",
"python3 scripts/verify-skin-polarity.py --all",
"python3 scripts/test-verify-skin-polarity.py",
"python3 scripts/verify-architecture-delta.py --all",
diff --git a/scripts/test-verify-beeswarm.py b/scripts/test-verify-beeswarm.py
index 05f8766..64e5652 100644
--- a/scripts/test-verify-beeswarm.py
+++ b/scripts/test-verify-beeswarm.py
@@ -661,7 +661,7 @@ def run_cases(h: Harness) -> int:
# against the siblings' real CLIs, not a re-implementation; siblings not
# yet landed (in-flight variant PRs) are legitimately absent.
for sibling in ("verify-slopegraph.py", "verify-bump.py",
- "verify-bubble.py"):
+ "verify-bubble.py", "verify-box-plot.py"):
script = ROOT / "scripts" / sibling
if not script.is_file():
print("skip %s not on this branch; treaty case not applicable"
diff --git a/scripts/test-verify-box-plot.py b/scripts/test-verify-box-plot.py
new file mode 100644
index 0000000..b735c15
--- /dev/null
+++ b/scripts/test-verify-box-plot.py
@@ -0,0 +1,1226 @@
+#!/usr/bin/env python3
+"""Adversarial cases for verify-box-plot.py, both polarities.
+
+Every case is named for exactly what it asserts. The negative half matters
+as much as the positive: a checker that fires on an honest figure, on the
+parent scatter, or on a sibling contract's files gets widened or switched
+off, and then it guards nothing.
+
+The scope treaty is pinned here in both directions: fixtures prove that
+`data-value` on a <circle> (the beeswarm contract) never claims a file for
+this checker, and every sibling per-file verifier present on the branch is
+run as a subprocess against the shipped box-plot examples and must skip
+all three.
+
+Fixtures live in a per-process temporary directory, never under the
+repository root.
+
+Exit: 0 all pass, 1 any failure.
+"""
+
+from __future__ import annotations
+
+import re
+import shutil
+import subprocess
+import sys
+import tempfile
+from pathlib import Path
+
+ROOT = Path(__file__).resolve().parent.parent
+sys.path.insert(0, str(ROOT / "scripts"))
+
+verify = __import__("verify-box-plot")
+
+ASSETS = ROOT / "skills/diagram-design/assets"
+SHIPPED = [ASSETS / name for name in (
+ "example-box-plot.html", "example-box-plot-dark.html",
+ "example-box-plot-full.html",
+)]
+
+HEAD = """<!DOCTYPE html>
+<html lang="en"><head><meta charset="UTF-8"><title>t</title></head><body>
+<svg viewBox="0 0 1000 500" xmlns="http://www.w3.org/2000/svg" role="img"
+ aria-labelledby="box-plot-title box-plot-desc">
+ <title id="box-plot-title">t</title>
+ <desc id="box-plot-desc">Box plot fixture.</desc>
+"""
+TAIL = "</svg></body></html>\n"
+
+INK = "rgba(45,49,66,0.15)"
+STROKE = "#4f5d75"
+ACCENT_FILL = "rgba(191,69,32,0.12)"
+ACCENT_STROKE = "#bf4520"
+
+
+def x(value: float) -> float:
+ return 160 + 2 * value
+
+
+def series(name, q1, q2, q3, wlo, whi, cy, *, focal=False, outliers=(),
+ q1_x=None, q3_x=None, q2_x=None, wlo_x=None, whi_x=None,
+ omit=None, extra="", outlier_x=None, outlier_inside=False,
+ label=None, label_y=None, median_x2=None, box_fill=None):
+ omit = omit or set()
+ box_x = x(q1) if q1_x is None else q1_x
+ box_r = x(q3) if q3_x is None else q3_x
+ med = x(q2) if q2_x is None else q2_x
+ lo = x(wlo) if wlo_x is None else wlo_x
+ hi = x(whi) if whi_x is None else whi_x
+ fill, stroke = (ACCENT_FILL, ACCENT_STROKE) if focal else (INK, STROKE)
+ if box_fill is not None:
+ fill = box_fill
+ y = cy - 16
+ attrs = []
+ if "name" not in omit:
+ attrs.append('data-name="%s"' % name)
+ if "q1" not in omit:
+ attrs.append('data-q1="%s"' % q1)
+ if "q2" not in omit:
+ attrs.append('data-q2="%s"' % q2)
+ if "q3" not in omit:
+ attrs.append('data-q3="%s"' % q3)
+ if "wlo" not in omit:
+ attrs.append('data-wlo="%s"' % wlo)
+ if "whi" not in omit:
+ attrs.append('data-whi="%s"' % whi)
+ body = []
+ if "whisker-lo" not in omit:
+ body.append(
+ ' <line data-role="whisker-lo" x1="%g" y1="%g" x2="%g" y2="%g" '
+ 'stroke="rgba(45,49,66,0.55)" stroke-width="1"/>'
+ % (lo, cy, box_x, cy)
+ )
+ if "whisker-hi" not in omit:
+ body.append(
+ ' <line data-role="whisker-hi" x1="%g" y1="%g" x2="%g" y2="%g" '
+ 'stroke="rgba(45,49,66,0.55)" stroke-width="1"/>'
+ % (box_r, cy, hi, cy)
+ )
+ if "box" not in omit:
+ body.append(
+ ' <rect data-role="box" x="%g" y="%g" width="%g" height="32" '
+ 'fill="%s" stroke="%s" stroke-width="1"/>'
+ % (box_x, y, box_r - box_x, fill, stroke)
+ )
+ if "median" not in omit:
+ body.append(
+ ' <line data-role="median" x1="%g" y1="%g" x2="%g" y2="%g" '
+ 'stroke="#2d3142" stroke-width="1.5"/>'
+ % (med, y, med if median_x2 is None else median_x2, y + 32)
+ )
+ for ov in outliers:
+ ox = x(ov) if outlier_x is None else outlier_x
+ if outlier_inside:
+ ox = med
+ body.append(
+ ' <circle data-outlier="%s" data-x="%s" cx="%g" cy="%g" r="4" '
+ 'fill="rgba(45,49,66,0.55)" stroke="#4f5d75"/>'
+ % (name, ov, ox, cy)
+ )
+ if "label" not in omit:
+ body.append(
+ ' <text data-name="%s" x="148" y="%g" text-anchor="end">%s</text>'
+ % (name, cy + 4 if label_y is None else label_y,
+ name if label is None else label)
+ )
+ return ' <g %s%s>\n%s\n </g>\n' % (
+ " ".join(attrs), (" " + extra) if extra else "", "\n".join(body)
+ )
+
+
+def tick(value, position=None, shown=None, declared=None, axis="x", extra=""):
+ if position is None:
+ position = x(value)
+ bind = "" if declared == "omit" else \
+ ' data-value="%s"' % (value if declared is None else declared)
+ return (
+ ' <text data-tick="%s"%s x="%g" y="440"%s>%s</text>\n'
+ % (axis, bind, position, (" " + extra) if extra else "",
+ ("%g" % value) if shown is None else shown)
+ )
+
+
+TICKS = tick(0) + tick(200) + tick(400)
+
+
+def honest(*extra: str) -> str:
+ return document(
+ series("A", 20, 30, 40, 10, 50, 80),
+ series("B", 40, 60, 90, 20, 120, 160, focal=True, outliers=(180,)),
+ series("C", 15, 22, 28, 8, 40, 240),
+ TICKS,
+ *extra,
+ )
+
+
+def prepend_style(css: str) -> str:
+ return honest().replace("<svg ", "<style>%s</style>\n<svg " % css, 1)
+
+
+A_LABEL = '<text data-name="A" x="148" y="84" text-anchor="end">A</text>'
+A_BOX = 'data-role="box" x="200"'
+
+AUTH_G = '<g data-name="Auth"'
+AUTH_BOX = ('<rect data-role="box" x="196" y="64.0" width="20" height="32" rx="2" '
+ 'fill="rgba(45,49,66,0.15)" stroke="#4f5d75" stroke-width="1"/>')
+CHECKOUT_BOX = ('<rect data-role="box" x="320" y="200.0" width="240" height="32" '
+ 'rx="2" fill="rgba(191,69,32,0.12)" stroke="#bf4520"')
+
+
+def shipped_with(*swaps: tuple, index: int = 0) -> str:
+ """A shipped example with each (old, new) swap applied exactly once."""
+ source = SHIPPED[index].read_text(encoding="utf-8")
+ for old, new in swaps:
+ assert source.count(old) == 1, "fixture anchor %r is not unique" % old
+ source = source.replace(old, new)
+ return source
+
+
+def auth_fill(paint: str) -> tuple:
+ return AUTH_BOX, AUTH_BOX.replace('fill="rgba(45,49,66,0.15)"', paint, 1)
+
+
+def styled(css: str) -> tuple:
+ return " </style>", " %s\n </style>" % css
+
+
+def document(*blocks: str) -> str:
+ return HEAD + "".join(blocks) + TAIL
+
+
+class Harness:
+ def __init__(self):
+ self.failures = 0
+ self.count = 0
+ self.dir = Path(tempfile.mkdtemp(prefix="box-plot-fixtures-"))
+
+ def close(self):
+ shutil.rmtree(self.dir, ignore_errors=True)
+
+ def path_for(self, name: str) -> Path:
+ return self.dir / name
+
+ def run(self, source: str, name: str = "example-box-plot-fixture.html") -> list:
+ path = self.path_for(name)
+ path.write_text(source, encoding="utf-8")
+ try:
+ return verify.check(path)
+ except Exception as error: # pragma: no cover - the checker must not raise
+ return ["<exception> %s: %s" % (type(error).__name__, error)]
+
+ def check(self, title: str, ok: bool, detail: str = "") -> None:
+ self.count += 1
+ if ok:
+ print("ok %s" % title)
+ return
+ self.failures += 1
+ print("FAIL %s" % title)
+ if detail:
+ print(" %s" % detail)
+
+ def expect_clean(self, title: str, source: str, **kw) -> None:
+ findings = self.run(source, **kw)
+ self.check(title, findings == [], "findings=%s" % findings)
+
+ def expect_findings(self, title: str, source: str, n: int, needle: str,
+ **kw) -> None:
+ findings = self.run(source, **kw)
+ ok = len(findings) == n and any(needle in item for item in findings)
+ self.check(
+ title, ok,
+ "expected %d finding(s) containing %r; got %s"
+ % (n, needle, findings),
+ )
+
+ def expect_named(self, title: str, source: str, needle: str, **kw) -> None:
+ findings = self.run(source, **kw)
+ self.check(
+ title,
+ bool(findings) and any(needle in item for item in findings),
+ "expected at least one finding containing %r; got %s"
+ % (needle, findings),
+ )
+
+ def expect_out_of_scope(self, title: str, source: str, name: str) -> None:
+ path = self.path_for(name)
+ path.write_text(
+ "<!DOCTYPE html><html><body>%s</body></html>" % source,
+ encoding="utf-8",
+ )
+ findings = verify.check(path)
+ detected = verify.looks_like_box_plot(path, path.read_text(encoding="utf-8"))
+ self.check(
+ title,
+ findings == [] and not detected,
+ "detected=%s findings=%s" % (detected, findings),
+ )
+
+
+def main() -> int:
+ h = Harness()
+ try:
+ return run_cases(h)
+ finally:
+ h.close()
+
+
+def run_cases(h: Harness) -> int:
+ for path in SHIPPED:
+ h.check("shipped %s exists" % path.name, path.is_file())
+ findings = verify.check(path)
+ h.check(
+ "shipped %s is clean" % path.name,
+ findings == [],
+ "findings=%s" % findings,
+ )
+
+ h.expect_clean("an honest synthetic box plot passes", honest())
+
+ h.expect_findings(
+ "a median drawn off q2 is one finding",
+ honest().replace(
+ series("B", 40, 60, 90, 20, 120, 160, focal=True, outliers=(180,)),
+ series("B", 40, 60, 90, 20, 120, 160, focal=True, outliers=(180,),
+ q2_x=x(60) + 12),
+ 1,
+ ),
+ 1, "median line",
+ )
+
+ h.expect_named(
+ "a box whose right edge is not q3 is a finding",
+ honest().replace(
+ series("A", 20, 30, 40, 10, 50, 80),
+ series("A", 20, 30, 40, 10, 50, 80, q3_x=x(40) + 20),
+ 1,
+ ),
+ "right edge",
+ )
+
+ h.expect_findings(
+ "a low whisker that misses wlo is one finding",
+ honest().replace(
+ series("A", 20, 30, 40, 10, 50, 80),
+ series("A", 20, 30, 40, 10, 50, 80, wlo_x=x(10) + 16),
+ 1,
+ ),
+ 1, "low whisker",
+ )
+
+ h.expect_findings(
+ "an outlier declared inside the whiskers is one finding",
+ document(
+ series("A", 20, 30, 40, 10, 50, 80),
+ series("B", 40, 60, 90, 20, 120, 160, focal=True, outliers=(80,)),
+ series("C", 15, 22, 28, 8, 40, 240),
+ TICKS,
+ ),
+ 1, "inside the whiskers",
+ )
+
+ h.expect_findings(
+ "a second accent series is one finding",
+ document(
+ series("A", 20, 30, 40, 10, 50, 80, focal=True),
+ series("B", 40, 60, 90, 20, 120, 160, focal=True),
+ series("C", 15, 22, 28, 8, 40, 240),
+ TICKS,
+ ),
+ 1, "at most one focal",
+ )
+
+ h.expect_findings(
+ "q2 greater than q3 is one finding",
+ document(
+ series("A", 20, 45, 40, 10, 50, 80),
+ series("B", 40, 60, 90, 20, 120, 160, focal=True),
+ series("C", 15, 22, 28, 8, 40, 240),
+ TICKS,
+ ),
+ 1, "ordered",
+ )
+
+ h.expect_named(
+ "a transform on a box is a finding",
+ honest().replace(
+ series("A", 20, 30, 40, 10, 50, 80),
+ series("A", 20, 30, 40, 10, 50, 80, extra='transform="translate(8,0)"'),
+ 1,
+ ),
+ "positions a mark",
+ )
+
+ h.expect_findings(
+ "an outlier outside the whiskers but inside the Tukey fence is one finding",
+ honest().replace(
+ series("B", 40, 60, 90, 20, 120, 160, focal=True, outliers=(180,)),
+ series("B", 40, 60, 90, 20, 120, 160, focal=True, outliers=(150,)),
+ 1,
+ ),
+ 1, "Tukey fences",
+ )
+
+ h.expect_findings(
+ "a whisker that reaches past the Tukey fence is one finding",
+ honest().replace(
+ series("A", 20, 30, 40, 10, 50, 80),
+ series("A", 20, 30, 40, 10, 75, 80),
+ 1,
+ ),
+ 1, "reach past the Tukey fences",
+ )
+
+ h.expect_findings(
+ "a slanted median whose second end misses q2 is one finding",
+ honest().replace(
+ series("A", 20, 30, 40, 10, 50, 80),
+ series("A", 20, 30, 40, 10, 50, 80, median_x2=x(30) + 40),
+ 1,
+ ),
+ 1, "median line",
+ )
+
+ h.expect_findings(
+ "a high whisker detached from the box is one finding",
+ honest().replace(
+ '<line data-role="whisker-hi" x1="%g" y1="80"' % x(40),
+ '<line data-role="whisker-hi" x1="%g" y1="80"' % (x(40) + 10),
+ 1,
+ ),
+ 1, "high whisker's box end",
+ )
+
+ h.expect_findings(
+ "a whisker drawn on another row is one finding",
+ honest().replace(
+ 'x2="%g" y2="80" stroke="rgba(45,49,66,0.55)"' % x(50),
+ 'x2="%g" y2="160" stroke="rgba(45,49,66,0.55)"' % x(50),
+ 1,
+ ),
+ 1, "off the row centre",
+ )
+
+ h.expect_clean(
+ "series wrapped in a plain <g> are all still read",
+ document(
+ " <g class=\"series\">\n",
+ series("A", 20, 30, 40, 10, 50, 80),
+ series("B", 40, 60, 90, 20, 120, 160, focal=True, outliers=(180,)),
+ series("C", 15, 22, 28, 8, 40, 240),
+ " </g>\n",
+ TICKS,
+ ),
+ )
+
+ h.expect_named(
+ "a wrapped series is not dropped from the checks",
+ document(
+ " <g class=\"series\">\n",
+ series("A", 20, 30, 40, 10, 50, 80, q3_x=x(40) + 20),
+ series("B", 40, 60, 90, 20, 120, 160, focal=True, outliers=(180,)),
+ series("C", 15, 22, 28, 8, 40, 240),
+ series("D", 12, 18, 24, 6, 36, 320),
+ " </g>\n",
+ TICKS,
+ ),
+ "series 'A' the box's right edge",
+ )
+
+ h.expect_named(
+ "an inline style width on a box is a finding",
+ honest().replace(
+ 'width="40" height="32" fill="%s"' % INK,
+ 'width="40" height="32" style="width: 60px" fill="%s"' % INK,
+ 1,
+ ),
+ "the width property",
+ )
+
+ h.expect_findings(
+ "a <style> rule sizing rect is one finding",
+ honest().replace("<svg ", "<style>rect { width: 300px; }</style>\n<svg ", 1),
+ 1, "box-size",
+ )
+
+ h.expect_clean(
+ "a <style> rule sizing only the <svg> is not a finding",
+ honest().replace("<svg ", "<style>svg { width: 100%; }</style>\n<svg ", 1),
+ )
+
+ h.expect_findings(
+ "a label that names another series is one finding",
+ honest().replace(
+ series("A", 20, 30, 40, 10, 50, 80),
+ series("A", 20, 30, 40, 10, 50, 80, label="C"),
+ 1,
+ ),
+ 1, "must name the series",
+ )
+
+ h.expect_findings(
+ "a label parked beside another row is one finding",
+ honest().replace(
+ series("A", 20, 30, 40, 10, 50, 80),
+ series("A", 20, 30, 40, 10, 50, 80, label_y=164),
+ 1,
+ ),
+ 1, "off its row",
+ )
+
+ h.expect_findings(
+ "a series with no bound label is one finding",
+ honest().replace(
+ series("A", 20, 30, 40, 10, 50, 80),
+ series("A", 20, 30, 40, 10, 50, 80, omit={"label"}),
+ 1,
+ ),
+ 1, "bound category labels",
+ )
+
+ for accent in (ACCENT_FILL, "rgba(240,138,89,0.12)"):
+ h.expect_findings(
+ "a second box with an accent fill %s and muted stroke is one finding"
+ % accent,
+ honest().replace(
+ series("A", 20, 30, 40, 10, 50, 80),
+ series("A", 20, 30, 40, 10, 50, 80, box_fill=accent),
+ 1,
+ ),
+ 1, "at most one focal",
+ )
+
+ h.expect_findings(
+ "an accent outlier on a muted series is one finding",
+ honest().replace(
+ series("C", 15, 22, 28, 8, 40, 240),
+ series("C", 15, 22, 28, 8, 40, 240, outliers=(60,)).replace(
+ 'fill="rgba(45,49,66,0.55)" stroke="#4f5d75"/>',
+ 'fill="rgba(191,69,32,0.55)" stroke="#bf4520"/>'),
+ 1,
+ ),
+ 1, "at most one focal",
+ )
+
+ h.expect_findings(
+ "a declared outlier with no data-x is one finding",
+ honest().replace('data-outlier="B" data-x="180" ', 'data-outlier="B" ', 1),
+ 1, "no data-x",
+ )
+
+ h.expect_findings(
+ "a tick that prints the wrong number is one finding",
+ honest().replace(tick(200), tick(200, shown="350"), 1),
+ 1, "prints",
+ )
+
+ h.expect_findings(
+ "a data-tick=y label is one finding",
+ honest() + tick(0, axis="y"),
+ 1, 'data-tick="y"' if False else "label rail",
+ )
+
+ h.expect_findings(
+ "two series sharing a name is one finding",
+ document(
+ series("A", 20, 30, 40, 10, 50, 80),
+ series("A", 40, 60, 90, 20, 120, 160, focal=True),
+ series("C", 15, 22, 28, 8, 40, 240),
+ TICKS,
+ ),
+ 1, "share data-name",
+ )
+
+ h.expect_findings(
+ "two series is fail-closed",
+ document(
+ series("A", 20, 30, 40, 10, 50, 80),
+ series("B", 40, 60, 90, 20, 120, 160, focal=True),
+ TICKS,
+ ),
+ 1, "2 verifiable",
+ )
+
+ h.expect_named(
+ "a missing median is a finding",
+ document(
+ series("A", 20, 30, 40, 10, 50, 80, omit={"median"}),
+ series("B", 40, 60, 90, 20, 120, 160, focal=True),
+ series("C", 15, 22, 28, 8, 40, 240),
+ series("D", 12, 18, 24, 6, 36, 320),
+ TICKS,
+ ),
+ "median",
+ )
+
+ h.expect_findings(
+ "a data-outlier circle outside its series group is one finding",
+ honest().replace(
+ "</svg>",
+ ' <circle data-outlier="B" data-x="300" cx="760" cy="160" r="4"/>\n'
+ "</svg>",
+ 1,
+ ),
+ 1, "not inside that",
+ )
+
+ b_dot = (
+ ' <circle data-outlier="B" data-x="180" cx="%g" cy="160" r="4" '
+ 'fill="rgba(45,49,66,0.55)" stroke="#4f5d75"/>' % x(180)
+ )
+ h.expect_findings(
+ "outliers moved into their own layer are one finding",
+ honest().replace(b_dot + "\n", "").replace(
+ "</svg>",
+ '<g class="outliers">\n%s\n</g>\n</svg>'
+ % b_dot.replace('data-x="180"', 'data-x="300"'),
+ 1,
+ ),
+ 1, "not inside that",
+ )
+
+ h.expect_findings(
+ "a :nth-child size rule reaches a box",
+ prepend_style('g[data-name="A"] > :nth-child(6) { width: 300px }'),
+ 1, "box-size",
+ )
+ h.expect_findings(
+ "a :not() size rule with no typed subject reaches a box",
+ prepend_style("[data-q1] :not(text):not(line):not(circle) { width: 300px }"),
+ 1, "box-size",
+ )
+ h.expect_findings(
+ "a backslash escape in a selector is one finding",
+ prepend_style(r"r\000065ct { width: 300px }"),
+ 1, "backslash",
+ )
+ h.expect_findings(
+ "a CSS comment hiding a width rule is one finding",
+ prepend_style("rect{/**/width:300px}"),
+ 1, "box-size",
+ )
+ h.expect_findings(
+ "a CSS comment hiding a transform is one finding",
+ prepend_style("rect{/**/transform:translateX(100px)}"),
+ 1, "positions a mark",
+ )
+ h.expect_named(
+ "an inline style comment hiding a width is a finding",
+ honest().replace(
+ 'width="40" height="32" fill="%s"' % INK,
+ 'width="40" height="32" style="/**/width:300px" fill="%s"' % INK,
+ 1,
+ ),
+ "the width property",
+ )
+ h.expect_named(
+ "a backslash escape in an inline style is a finding",
+ honest().replace(
+ 'width="40" height="32" fill="%s"' % INK,
+ 'width="40" height="32" style="width:\\33 00px" fill="%s"' % INK,
+ 1,
+ ),
+ "backslash",
+ )
+ h.expect_findings(
+ "a stylesheet link other than the font link is one finding",
+ honest().replace(
+ "<svg ",
+ '<link rel="stylesheet" href="data:text/css,rect%7Bwidth:300px%7D">\n'
+ "<svg ",
+ 1,
+ ),
+ 1, "stylesheet link",
+ )
+ h.expect_clean(
+ "the Google font stylesheet link is not a finding",
+ honest().replace(
+ "<svg ",
+ '<link rel="stylesheet" href="https://fonts.googleapis.com/css2?'
+ 'family=Geist&display=swap">\n<svg ',
+ 1,
+ ),
+ )
+ h.expect_findings(
+ "a <set> inside the figure is one finding",
+ honest().replace(
+ " <rect %s" % A_BOX,
+ ' <set attributeName="width" to="300"/>\n <rect %s' % A_BOX,
+ 1,
+ ),
+ 1, "<set>",
+ )
+ h.expect_findings(
+ "an <animate> inside the figure is one finding",
+ honest().replace(
+ "</svg>",
+ ' <animate attributeName="x" to="120"/>\n</svg>',
+ 1,
+ ),
+ 1, "<animate>",
+ )
+
+ h.expect_findings(
+ "dx/dy on a bound label is one finding",
+ honest().replace(A_LABEL, A_LABEL.replace(" y=", ' dy="136" y=', 1), 1),
+ 1, "dx/dy",
+ )
+ h.expect_findings(
+ "a positioned tspan in a bound label is one finding",
+ honest().replace(
+ A_LABEL,
+ '<text data-name="A" x="148" y="84" text-anchor="end">'
+ '<tspan y="220">A</tspan></text>',
+ 1,
+ ),
+ 1, "<tspan>",
+ )
+ h.expect_clean(
+ "an unpositioned tspan in a bound label is not a finding",
+ honest().replace(
+ A_LABEL,
+ '<text data-name="A" x="148" y="84" text-anchor="end">'
+ "<tspan>A</tspan></text>",
+ 1,
+ ),
+ )
+ h.expect_findings(
+ "a label drawn off the label rail is one finding",
+ honest().replace(A_LABEL, A_LABEL.replace('x="148"', 'x="-500"', 1), 1),
+ 1, "label rail",
+ )
+ h.expect_findings(
+ "a hidden bound label is one finding",
+ honest().replace(
+ A_LABEL,
+ A_LABEL.replace("<text ", '<text opacity="0" ', 1)
+ + '<text x="148" y="84">Catalog</text>',
+ 1,
+ ),
+ 1, "hides its bound label",
+ )
+
+ h.expect_findings(
+ "an inline accent fill on a muted box is one finding",
+ honest().replace(
+ 'x="200" y="64" width="40" height="32" fill="%s"' % INK,
+ 'x="200" y="64" width="40" height="32" style="fill:#bf4520" fill="%s"'
+ % INK,
+ 1,
+ ),
+ 1, "at most one focal",
+ )
+ h.expect_findings(
+ "a class rule painting a muted box with the accent is one finding",
+ prepend_style(".hot{fill:#bf4520}").replace(
+ A_BOX, 'data-role="box" class="hot" x="200"', 1),
+ 1, "at most one focal",
+ )
+ for accent in ("#bf4520ff", "rgb(191,69,32)"):
+ h.expect_findings(
+ "accent fill %s on a muted box is one finding" % accent,
+ honest().replace(
+ series("A", 20, 30, 40, 10, 50, 80),
+ series("A", 20, 30, 40, 10, 50, 80, box_fill=accent),
+ 1,
+ ),
+ 1, "at most one focal",
+ )
+ h.expect_findings(
+ "an accent fill on the paper underlay is one finding",
+ honest().replace(
+ " <rect %s" % A_BOX,
+ ' <rect x="200" y="64" width="40" height="32" fill="#bf4520"/>\n'
+ " <rect %s" % A_BOX,
+ 1,
+ ),
+ 1, "at most one focal",
+ )
+ h.expect_findings(
+ "an accent stroke on the median is one finding",
+ honest().replace(
+ 'data-role="median" x1="220" y1="64" x2="220" y2="96" stroke="#2d3142"',
+ 'data-role="median" x1="220" y1="64" x2="220" y2="96" stroke="#bf4520"',
+ 1,
+ ),
+ 1, "at most one focal",
+ )
+
+ block = series("A", 20, 30, 40, 10, 50, 80)
+ h.expect_findings(
+ "a nested svg viewport shifting a series is one finding",
+ honest().replace(
+ block, '<svg x="120" overflow="visible">\n%s</svg>\n' % block, 1),
+ 1, "nested <svg>",
+ )
+ h.expect_findings(
+ "a <use> shifting a series is one finding",
+ honest().replace("</svg>", ' <use href="#auth" x="120"/>\n</svg>', 1),
+ 1, "<use>",
+ )
+ hidden = block.replace("<g ", '<g id="auth" ', 1)
+ drawn = block.replace(' data-q1="20"', "", 1)
+ stashed = honest().replace(
+ block, "<defs>\n%s</defs>\n%s" % (hidden, drawn), 1)
+ h.expect_named(
+ "a series stashed in <defs> is a finding",
+ stashed, "non-rendering",
+ )
+ h.expect_named(
+ "a series stashed in <defs> after a self-closing <mask/> is a finding",
+ honest().replace(
+ block, "<defs>\n<mask/>\n%s</defs>\n%s" % (hidden, drawn), 1),
+ "non-rendering",
+ )
+ h.expect_named(
+ "a drawn copy with no data-q1 is a finding",
+ stashed, "outside every series",
+ )
+
+ h.expect_findings(
+ "a second median off q2 is one finding",
+ honest().replace(
+ 'data-role="median" x1="220" y1="64" x2="220" y2="96" '
+ 'stroke="#2d3142" stroke-width="1.5"/>',
+ 'data-role="median" x1="220" y1="64" x2="220" y2="96" '
+ 'stroke="#2d3142" stroke-width="1.5"/>\n'
+ ' <line data-role="median" x1="500" y1="64" x2="500" y2="96" '
+ 'stroke="#2d3142" stroke-width="1.5"/>',
+ 1,
+ ),
+ 1, "median line",
+ )
+ h.expect_findings(
+ "a cap off the whisker end is one finding",
+ honest().replace(
+ ' <line data-role="whisker-hi" x1="240" y1="80" x2="260" y2="80" '
+ 'stroke="rgba(45,49,66,0.55)" stroke-width="1"/>',
+ ' <line data-role="whisker-hi" x1="240" y1="80" x2="260" y2="80" '
+ 'stroke="rgba(45,49,66,0.55)" stroke-width="1"/>\n'
+ ' <line data-role="cap" x1="800" y1="72" x2="800" y2="88" '
+ 'stroke="#4f5d75"/>',
+ 1,
+ ),
+ 1, "cap",
+ )
+ h.expect_findings(
+ "an unbound circle inside a series is one finding",
+ honest().replace(
+ A_LABEL,
+ ' <circle cx="300" cy="80" r="4" fill="#4f5d75"/>\n ' + A_LABEL,
+ 1,
+ ),
+ 1, "paper mask",
+ )
+ papered = honest().replace(
+ " <g ", ' <rect width="100%" height="100%" fill="#f5f5f5"/>\n <g ', 1)
+ mask = '<circle cx="520" cy="160" r="4" fill="#f5f5f5"/>\n '
+ h.expect_clean(
+ "a paper mask on a bound outlier is not a finding",
+ papered.replace('<circle data-outlier="B"', mask + '<circle data-outlier="B"', 1),
+ )
+ h.expect_findings(
+ "a paper mask repainted by an inline style is one finding",
+ papered.replace(
+ '<circle data-outlier="B"',
+ mask.replace("/>", ' style="fill:#4f5d75"/>', 1) + '<circle data-outlier="B"',
+ 1,
+ ),
+ 1, "paper mask",
+ )
+ h.expect_findings(
+ "an <animateColor> inside the figure is one finding",
+ honest().replace(
+ "</svg>", ' <animateColor attributeName="fill" to="#bf4520"/>\n</svg>', 1),
+ 1, "<animatecolor>",
+ )
+ h.expect_findings(
+ "an accent fill inherited from a muted series group is one finding",
+ honest().replace(block, block.replace("<g ", '<g fill="#bf4520" ', 1), 1),
+ 1, "at most one focal",
+ )
+ h.expect_findings(
+ "an accent path inside a muted series is one finding",
+ honest().replace(
+ A_LABEL, '<path d="M200 64h40v32h-40z" fill="#bf4520"/>\n ' + A_LABEL, 1),
+ 1, "at most one focal",
+ )
+ h.expect_findings(
+ "a paper mask inheriting a group stroke is one finding",
+ papered.replace(
+ '<circle data-outlier="B"', mask + '<circle data-outlier="B"', 1,
+ ).replace('<g data-name="B"', '<g stroke="#4f5d75" data-name="B"', 1),
+ 1, "paper mask",
+ )
+ h.expect_findings(
+ "a paper mask inheriting a wrapper stroke is one finding",
+ papered.replace(
+ '<circle data-outlier="B"', mask + '<circle data-outlier="B"', 1,
+ ).replace(' <g data-name="B"', ' <g stroke="#4f5d75">\n <g data-name="B"', 1
+ ).replace("</svg>", " </g>\n</svg>", 1),
+ 1, "paper mask",
+ )
+ h.expect_findings(
+ "a hidden tspan inside a bound label is one finding",
+ honest().replace(
+ A_LABEL,
+ '<text data-name="A" x="148" y="84" text-anchor="end">'
+ '<tspan opacity="0">A</tspan></text>',
+ 1,
+ ),
+ 1, "hides its bound label",
+ )
+ h.expect_findings(
+ "a descendant class rule painting a muted series with the accent is one finding",
+ prepend_style(".hot rect{fill:#bf4520}").replace(
+ block, block.replace("<g ", '<g class="hot" ', 1), 1),
+ 1, "at most one focal",
+ )
+ h.expect_findings(
+ "a polygon class rule painting a muted series with the accent is one finding",
+ prepend_style("polygon.hot{fill:#bf4520}").replace(
+ A_LABEL,
+ '<polygon class="hot" points="200,64 240,64 240,96"/>\n ' + A_LABEL,
+ 1,
+ ),
+ 1, "at most one focal",
+ )
+ h.expect_findings(
+ "a cap on the whisker end but off its row is one finding",
+ honest().replace(
+ A_LABEL,
+ '<line data-role="cap" x1="260" y1="200" x2="260" y2="216" '
+ 'stroke="#4f5d75"/>\n ' + A_LABEL,
+ 1,
+ ),
+ 1, "cap runs",
+ )
+
+ h.expect_out_of_scope(
+ "the parent scatter is not a box plot",
+ "<svg role='img'><title>t</title><desc>A scatter of latency against "
+ "errors.</desc>"
+ '<circle cx="200" cy="200" r="5" fill="rgba(45,49,66,0.20)"/>'
+ "</svg>",
+ "example-scatter-fixture.html",
+ )
+
+ a_block = series("A", 20, 30, 40, 10, 50, 80)
+ h.expect_findings(
+ "a second box rect in a series is one finding",
+ honest().replace(
+ A_LABEL,
+ '<rect data-role="box" x="200" y="64" width="160" height="32" '
+ 'fill="rgba(45,49,66,0.06)" stroke="#4f5d75"/>\n ' + A_LABEL,
+ 1,
+ ),
+ 1, "data-role=box marks",
+ )
+ h.expect_findings(
+ "a second whisker-hi in a series is one finding",
+ honest().replace(
+ A_LABEL,
+ '<line data-role="whisker-hi" x1="240" y1="80" x2="400" y2="80" '
+ 'stroke="rgba(45,49,66,0.55)" stroke-width="1"/>\n ' + A_LABEL,
+ 1,
+ ),
+ 1, "data-role=whisker-hi marks",
+ )
+ h.expect_named(
+ "bound marks wrapped in <defs> inside a visible series are a finding",
+ honest().replace(
+ a_block,
+ a_block.replace(' <line data-role="whisker-lo"',
+ ' <defs>\n <line data-role="whisker-lo"', 1)
+ .replace(" " + A_LABEL, " </defs>\n " + A_LABEL, 1),
+ 1,
+ ),
+ "non-rendering container",
+ )
+ shared = prepend_style(".series.focal rect{fill:#bf4520}")
+ for group in ('<g data-name="A"', '<g data-name="C"'):
+ shared = shared.replace(group, group.replace("<g ", '<g class="series" '), 1)
+ h.expect_clean(
+ "a compound class rule does not paint groups carrying only one of its classes",
+ shared.replace('<g data-name="B"', '<g class="series focal" data-name="B"', 1),
+ )
+ h.expect_findings(
+ "a compound class rule painting a second series is one finding",
+ shared.replace('<g class="series" data-name="A"',
+ '<g class="series focal" data-name="A"', 1),
+ 1, "at most one focal",
+ )
+ for rule in ("rect.hot:not(.muted){fill:#bf4520}", "rect:is(.hot){fill:#bf4520}"):
+ h.expect_named(
+ "a %s rule painting a muted box is a finding" % rule.split("{")[0],
+ prepend_style(rule).replace(A_BOX, 'class="hot" ' + A_BOX, 1),
+ "at most one focal",
+ )
+ h.expect_clean(
+ "a stroked sibling group does not repaint a paper mask",
+ papered.replace(
+ '<circle data-outlier="B"', mask + '<circle data-outlier="B"', 1,
+ ).replace(
+ ' <line data-role="whisker-lo" x1="200"',
+ ' <g stroke="#4f5d75"><line data-role="whisker-lo" x1="200"', 1,
+ ).replace(
+ 'x2="240" y2="160" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>',
+ 'x2="240" y2="160" stroke="rgba(45,49,66,0.55)" stroke-width="1"/></g>', 1,
+ ),
+ )
+ for radius, change in (("missing", ""), ("zero", ' r="0"')):
+ h.expect_findings(
+ "a bound outlier with a %s radius is one finding" % radius,
+ re.sub(r'(<circle data-outlier="B"[^>]*?) r="4"', r"\1" + change,
+ honest(), count=1),
+ 1, "positive radius",
+ )
+ stroked_root = papered.replace(
+ '<circle data-outlier="B"', mask + '<circle data-outlier="B"', 1,
+ ).replace("<svg viewBox", '<svg stroke="#4f5d75" viewBox', 1)
+ h.expect_clean(
+ "a series group's stroke=\"none\" overrides a root stroke on a paper mask",
+ stroked_root.replace('<g data-name="B"', '<g stroke="none" data-name="B"', 1),
+ )
+ h.expect_findings(
+ "a root stroke reaching a paper mask with no override is one finding",
+ stroked_root,
+ 1, "paper mask",
+ )
+ h.expect_findings(
+ "a class rule painting stroke:none on a series' rects does not "
+ "override a root stroke on a paper mask",
+ stroked_root.replace(" <g ", " <style>.hot rect{stroke:none}</style>\n <g ", 1
+ ).replace('<g data-name="B"', '<g class="hot" data-name="B"', 1),
+ 1, "paper mask",
+ )
+ outer_stroke = papered.replace(
+ '<circle data-outlier="B"', mask + '<circle data-outlier="B"', 1,
+ ).replace(' <g data-name="B"', ' <g class="outer">\n <g stroke="none" data-name="B"', 1
+ ).replace("</svg>", " </g>\n</svg>", 1)
+ h.expect_clean(
+ "stroke=\"none\" on a series overrides a class stroke on an outer group",
+ outer_stroke.replace(" <g ", " <style>.outer{stroke:#4f5d75}</style>\n <g ", 1),
+ )
+ h.expect_findings(
+ "a class rule stroking circles under an outer group reaches a paper mask "
+ "through an inner stroke=\"none\"",
+ outer_stroke.replace(
+ " <g ", " <style>.outer circle{stroke:#4f5d75}</style>\n <g ", 1),
+ 1, "paper mask",
+ )
+ h.expect_findings(
+ "a class rule stroking groups under an outer group reaches a paper mask",
+ papered.replace(
+ '<circle data-outlier="B"', mask + '<circle data-outlier="B"', 1,
+ ).replace(' <g data-name="B"', ' <g class="outer">\n <g data-name="B"', 1
+ ).replace("</svg>", " </g>\n</svg>", 1
+ ).replace(" <g ", " <style>.outer g{stroke:#4f5d75}</style>\n <g ", 1),
+ 1, "paper mask",
+ )
+
+ h.expect_findings(
+ "a class selector listed after a type-only one still repaints a paper mask",
+ papered.replace(
+ '<circle data-outlier="B"',
+ mask.replace("<circle ", '<circle class="m" ', 1) + '<circle data-outlier="B"', 1,
+ ).replace(" <g ", " <style>line, .m{stroke:#4f5d75}</style>\n <g ", 1),
+ 1, "paper mask",
+ )
+
+ # The accent and visibility as a browser resolves them, on the shipped
+ # example's muted Auth series: var(), hsl(), id and attribute selectors,
+ # and display/visibility/opacity on the series or a mark.
+ for title, swaps in (
+ ("an inline var(--color-accent) fill",
+ [(AUTH_BOX, AUTH_BOX.replace("/>", ' style="fill:var(--color-accent)"/>'))]),
+ ("a var() chained to the accent through another custom property",
+ [auth_fill('fill="var(--color-focus)"'),
+ ("--color-accent: #bf4520;",
+ "--color-accent: #bf4520;\n --color-focus: var(--color-accent);")]),
+ ("an hsl() spelling of the accent", [auth_fill('fill="hsl(14,71%,44%)"')]),
+ ("an hsla() spelling one rounding step off the accent",
+ [auth_fill('fill="hsla(13, 72%, 43%, 0.12)"')]),
+ ("a space-separated hsl() with a turn hue",
+ [auth_fill('fill="hsl(0.0388turn 71% 44% / 0.12)"')]),
+ ("an attribute selector", [styled('[data-name="Auth"] rect{fill:#bf4520}')]),
+ ("an id selector",
+ [styled("#auth rect{fill:#bf4520}"), (AUTH_G, '<g id="auth" data-name="Auth"')]),
+ ("a descendant attribute selector",
+ [styled('g[data-name="Auth"] [data-role="box"]{fill:#bf4520}')]),
+ ("a prefix attribute selector painting var(--color-accent)",
+ [styled('[data-name^="Au"] rect{stroke:var(--color-accent)}')]),
+ ):
+ h.expect_findings(
+ "%s on a muted series is one finding" % title,
+ shipped_with(*swaps), 1, "at most one focal",
+ )
+ h.expect_findings(
+ "an hsl() spelling of the dark accent on a muted series is one finding",
+ shipped_with(
+ ('x="196" y="64.0" width="20" height="32" rx="2" fill="rgba(245,245,245,0.14)"',
+ 'x="196" y="64.0" width="20" height="32" rx="2" fill="hsl(20,83%,64%)"'),
+ index=1),
+ 1, "at most one focal",
+ )
+ h.expect_named(
+ "a type selector painting the accent cannot be held to one series and "
+ "is a finding",
+ shipped_with(styled("rect{fill:#bf4520}")),
+ "at most one focal",
+ )
+ for title, swaps in (
+ ('display="none" on the series group', [(AUTH_G, '<g display="none" data-name="Auth"')]),
+ ('visibility="hidden" on the series group',
+ [(AUTH_G, '<g visibility="hidden" data-name="Auth"')]),
+ ('style="display:none" on the series group',
+ [(AUTH_G, '<g style="display:none" data-name="Auth"')]),
+ ('style="visibility:hidden" on the box',
+ [(AUTH_BOX, AUTH_BOX.replace("/>", ' style="visibility:hidden"/>'))]),
+ ('opacity="0" on the box', [(AUTH_BOX, AUTH_BOX.replace("/>", ' opacity="0"/>'))]),
+ ('display="none" on a wrapper group',
+ [(AUTH_G, '<g display="none">\n <g data-name="Auth"'),
+ (' <g data-name="Catalog"', ' </g>\n <g data-name="Catalog"')]),
+ ):
+ h.expect_findings(
+ "a series hidden by %s is one finding" % title,
+ shipped_with(*swaps), 1, "never drawn",
+ )
+ for title, swaps in (
+ ("the focal series painted through var(--color-accent)",
+ [(CHECKOUT_BOX, CHECKOUT_BOX.replace(
+ 'fill="rgba(191,69,32,0.12)" stroke="#bf4520"',
+ 'fill="var(--color-accent)" fill-opacity="0.12" stroke="var(--color-accent)"'))]),
+ ("an attribute selector painting only the focal series",
+ [styled('[data-name="Checkout"] rect{stroke:var(--color-accent)}')]),
+ ("a muted box stroked through var(--color-muted)",
+ [(AUTH_BOX, AUTH_BOX.replace('stroke="#4f5d75"', 'stroke="var(--color-muted)"'))]),
+ ("a muted hsl() fill", [auth_fill('fill="hsl(218,19%,38%)"')]),
+ ("a type selector painting a muted stroke", [styled("line{stroke:#4f5d75}")]),
+ ("a series group that states visibility and a nonzero opacity",
+ [(AUTH_G, '<g visibility="visible" opacity="0.9" data-name="Auth"')]),
+ ):
+ h.expect_clean("%s passes" % title, shipped_with(*swaps))
+
+ # A <style> rule hides as surely as an attribute. Rules tied to one
+ # series count against it; type-only rules count against every series
+ # they could reach, and so does a rule hiding an element around the svg.
+ for title, swaps, count in (
+ ('[data-name="Auth"]{display:none}',
+ [styled('[data-name="Auth"]{display:none}')], 1),
+ ("#auth{display:none} on the series id",
+ [styled("#auth{display:none}"), (AUTH_G, '<g id="auth" data-name="Auth"')], 1),
+ ('[data-name="Auth"] rect{visibility:hidden}',
+ [styled('[data-name="Auth"] rect{visibility:hidden}')], 1),
+ ('[data-name="Auth"] line{display:none !important}',
+ [styled('[data-name="Auth"] line{display:none !important}')], 1),
+ ("a type-only g{opacity:0}", [styled("g{opacity:0}")], 5),
+ (".frame{display:none} on the page element around the svg",
+ [styled(".frame{display:none}")], 5),
+ ):
+ h.expect_findings(
+ "a stylesheet rule %s is %d never-drawn finding(s)" % (title, count),
+ shipped_with(*swaps), count, "never drawn",
+ )
+ for title, css in (
+ ("a hiding rule on a class used only outside the svg", ".eyebrow{display:none}"),
+ ("a type-only hiding rule no chart element can match", "p{opacity:0}"),
+ ):
+ h.expect_clean("%s passes" % title, shipped_with(styled(css)))
+
+ # Every compound left of the subject must match a strict ancestor, in
+ # order: never the element itself, a sibling or a descendant.
+ for title, css, count, needle in (
+ ("body .frame{display:none} (a real ancestor)", "body .frame{display:none}",
+ 5, "never drawn"),
+ ('svg > g[data-name="Auth"]{display:none} (its real parent)',
+ 'svg > g[data-name="Auth"]{display:none}', 1, "never drawn"),
+ (".frame rect painting the accent (an ancestor outside the svg)",
+ ".frame rect{fill:#bf4520}", 1, "at most one focal"),
+ ('[role="img"] [data-name="Auth"] rect painting the accent',
+ '[role="img"] [data-name="Auth"] rect{fill:#bf4520}', 1, "at most one focal"),
+ ):
+ h.expect_findings(
+ "a rule %s is %d finding(s)" % (title, count),
+ shipped_with(styled(css)), count, needle,
+ )
+ for title, css in (
+ (".frame .frame{display:none} (no .frame around the .frame)",
+ ".frame .frame{display:none}"),
+ ('g g[data-name="Auth"]{display:none} (no <g> around Auth)',
+ 'g g[data-name="Auth"]{display:none}'),
+ ('[data-name="Auth"] [data-name="Auth"] rect painting the accent',
+ '[data-name="Auth"] [data-name="Auth"] rect{fill:#bf4520}'),
+ ('g [data-name="Auth"] rect painting the accent (no <g> around Auth)',
+ 'g [data-name="Auth"] rect{fill:#bf4520}'),
+ ):
+ h.expect_clean("a rule %s matches nothing and passes" % title,
+ shipped_with(styled(css)))
+
+ h.expect_out_of_scope(
+ "data-value on a <circle> never claims a file — the beeswarm contract",
+ "<svg role='img'><title>t</title><desc>A beeswarm of requests.</desc>"
+ '<circle data-value="90" cx="260" cy="230" r="4"/>'
+ "</svg>",
+ "fixture.html",
+ )
+
+ h.check(
+ "no shipped box-plot file declares data-value on a circle, data-series, "
+ "data-ranks or data-size, so no sibling verifier claims one",
+ all(not re.search(r"<circle[^>]*data-value\s*=",
+ path.read_text(encoding="utf-8"))
+ and not re.search(r"data-(series|ranks|size)\s*=",
+ path.read_text(encoding="utf-8"))
+ for path in SHIPPED),
+ )
+
+ for sibling in ("verify-slopegraph.py", "verify-bump.py",
+ "verify-bubble.py", "verify-beeswarm.py"):
+ script = ROOT / "scripts" / sibling
+ if not script.is_file():
+ print("skip %s not on this branch; treaty case not applicable"
+ % sibling)
+ continue
+ result = subprocess.run(
+ [sys.executable, str(script)] + [str(p) for p in SHIPPED],
+ capture_output=True, text=True,
+ )
+ h.check(
+ "%s skips all three shipped box-plot files" % sibling,
+ result.returncode == 0
+ and "3 file(s) skipped as out of scope" in result.stdout,
+ "exit=%d stdout=%s" % (result.returncode, result.stdout.strip()),
+ )
+
+ sentinel = ROOT / "example-box-plot-fixture.html"
+ existed = sentinel.exists()
+ if not existed:
+ sentinel.write_text("KEEP ME\n", encoding="utf-8")
+ try:
+ h.run(honest())
+ h.check(
+ "a pre-existing file sharing a fixture name is never touched",
+ sentinel.exists() and sentinel.read_text(encoding="utf-8") == "KEEP ME\n",
+ "%s was overwritten or deleted by the harness" % sentinel,
+ )
+ finally:
+ if not existed and sentinel.exists():
+ sentinel.unlink()
+
+ h.check(
+ "fixtures are written outside the repository",
+ not str(h.dir).startswith(str(ROOT)),
+ "fixture dir %s is inside %s" % (h.dir, ROOT),
+ )
+
+ print()
+ if h.failures:
+ print("%d of %d case(s) failed." % (h.failures, h.count))
+ return 1
+ print("OK box-plot checker: %d case(s), both polarities" % h.count)
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/scripts/verify-box-plot.py b/scripts/verify-box-plot.py
new file mode 100644
index 0000000..371eddb
--- /dev/null
+++ b/scripts/verify-box-plot.py
@@ -0,0 +1,1705 @@
+#!/usr/bin/env python3
+"""Verify that a box plot's drawn marks match the five-number values they declare.
+
+A box plot makes one hard claim: every box, median, whisker and outlier sits
+EXACTLY at its value on one shared linear value axis. The perpendicular
+(category) axis is a label rail — it carries no value. Both halves can be
+broken without anything erroring: a box nudged along the value axis "to open
+up space" renders fine and reads as a different quartile, and an outlier
+drawn inside the whisker turns a genuine extreme into a point on the fence.
+
+`lint-skin.py` reads colors and fonts and `verify-geometry.py` reads label
+masks; neither compares a drawn coordinate against the five-number summary
+bound to it.
+
+Ten invariants:
+
+1. SHARED VALUE SCALE - every mark's position on the value axis must sit
+ where one linear scale puts its declared value. The scale is derived from
+ the distinct values (Theil-Sen, leave-one-out), so one dishonest mark
+ cannot drag the line it is measured against.
+
+2. FIVE-NUMBER ORDER - each series declares wlo ≤ q1 ≤ q2 ≤ q3 ≤ whi as
+ finite numbers. A median outside its box, or a whisker that grows inward,
+ is not a five-number summary.
+
+3. BOX GEOMETRY - the stroked box rect's left edge is q1 and its right edge
+ is q3 on that scale. Width is not decoration.
+
+4. MEDIAN GEOMETRY - the median is a vertical line at q2, both ends, running
+ from the box's top edge to its bottom edge.
+
+5. WHISKER GEOMETRY - whisker-lo runs from wlo to q1 and whisker-hi from q3
+ to whi, horizontal through the box's row centre.
+
+6. TUKEY FENCES - whiskers stay inside [q1 - 1.5 IQR, q3 + 1.5 IQR], and
+ every outlier sits strictly outside both the whiskers and those fences,
+ at its declared value. A circle with data-outlier must bind data-x and
+ must sit inside the series group that name points at. An inlier drawn
+ as a dot is a box plot wearing a beeswarm costume. A cap, when drawn,
+ sits on a whisker end and crosses the whisker's row. An unbound circle
+ inside a series is allowed only as a paper mask sharing an outlier's
+ centre, painted only with the paper colour.
+
+7. AT MOST ONE ACCENT SERIES - one focal claim per figure, on either skin.
+ Fill and stroke are read from the attribute, the inline style and
+ <style> rules, on the series group, any nested group, and every shape
+ inside it: underlay, box, median, whiskers, caps, outliers and any
+ path, and on any group, the <svg> or page element around the series,
+ since paint inherits. Hex may carry alpha; rgb() counts as rgba();
+ hsl()/hsla() is converted and held to the accent within whole-number
+ rounding; var() resolves through every custom property the document
+ declares, unscoped. A rule counts on an element its selector matches:
+ the subject by type, class, id and attribute, every other compound on
+ a strict ancestor, in order. A type-only rule reaches every element of
+ that type.
+
+8. BOUND LABELS - each series carries exactly one <text data-name> whose
+ data-name and printed text both match the series, on the series' row
+ and on the label rail left of the value axis. dx/dy, a positioned
+ <tspan>, and a hiding attribute are refused.
+
+9. UNPOSITIONED GEOMETRY - every coordinate read here is a raw attribute.
+ A `transform` attribute, an inline `style`, or a rule in a <style> block
+ on a mark, a bound label or tick, or an ancestor is refused rather than
+ resolved, as in verify-beeswarm.py. CSS width/height on a box rect is
+ refused too (a <style> rule only when its selector can reach a box).
+ CSS comments are whitespace. A size rule whose subject has no type,
+ class, id or attribute reaches a box. Backslash escapes, stylesheet
+ links other than the font link, `<use>`, `<set>`/`<animate*>` and a
+ nested `<svg>` viewport are refused. A series inside `<defs>` is not
+ the series that gets drawn, and neither is a bound mark hidden by
+ display, visibility or opacity on itself, a group around it, the <svg>
+ or a page element around that. An attribute, an inline style and a
+ <style> rule all count; a rule's selector is held to the element it
+ names, and a type-only rule reaches every element of that type.
+
+10. FAIL CLOSED - a file that presents as a box plot but yields fewer than
+ three series on three distinct medians is a finding, never a pass. Three
+ because the scale test is leave-one-out and each fit needs two intervals.
+
+Vocabulary treaty: `data-q1` ON A <g> is the box-plot contract. Detection is
+deliberately element-scoped so a source-wide regex cannot claim a sibling.
+`data-value` on a <circle> is the beeswarm contract and is never bound here.
+`data-size` (bubble), `data-series` (slopegraph) and `data-ranks` (bump) are
+never bound here either.
+
+Usage:
+ python3 scripts/verify-box-plot.py --all
+ python3 scripts/verify-box-plot.py skills/diagram-design/assets/example-box-plot.html
+
+Exit: 0 clean, 1 findings, 2 usage.
+"""
+
+from __future__ import annotations
+
+import argparse
+import colorsys
+import html
+import math
+import re
+import sys
+from pathlib import Path
+
+ROOT = Path(__file__).resolve().parent.parent
+ASSET_DIR = ROOT / "skills/diagram-design/assets"
+
+CIRCLE_RE = re.compile(r"<circle\b(?P<attrs>[^>]*?)/?>", re.IGNORECASE)
+RECT_RE = re.compile(r"<rect\b(?P<attrs>[^>]*?)/?>", re.IGNORECASE)
+LINE_RE = re.compile(r"<line\b(?P<attrs>[^>]*?)/?>", re.IGNORECASE)
+TEXT_RE = re.compile(r"<text\b(?P<attrs>[^>]*)>(?P<body>.*?)</text>",
+ re.IGNORECASE | re.DOTALL)
+G_OPEN_RE = re.compile(r"<g\b(?P<attrs>[^>]*?)(?P<selfclose>/?)>", re.IGNORECASE)
+G_CLOSE_RE = re.compile(r"</g\s*>", re.IGNORECASE)
+COMMENT_RE = re.compile(r"<!--.*?-->", re.DOTALL)
+CSS_COMMENT_RE = re.compile(r"/\*.*?\*/", re.DOTALL)
+NAMED_RE = re.compile(r"<(?P<tag>title|desc)\b[^>]*>(?P<body>.*?)</(?P=tag)>",
+ re.IGNORECASE | re.DOTALL)
+GROUP_OPEN_RE = re.compile(r"<(?:g|svg)\b(?P<attrs>[^>]*?)(?P<selfclose>/?)>",
+ re.IGNORECASE)
+GROUP_CLOSE_RE = re.compile(r"</(?:g|svg)\s*>", re.IGNORECASE)
+STYLE_RE = re.compile(r"<style\b[^>]*>(?P<body>.*?)</style>",
+ re.IGNORECASE | re.DOTALL)
+CSS_MOVES_MARK_RE = re.compile(
+ r"(?:^|[{;}\n])\s*(?:-(?:webkit|moz|ms|o)-)?"
+ r"(?P<prop>transform|translate|rotate|scale"
+ r"|cx|cy|r|x|y|width|height"
+ r"|offset(?:-(?:path|distance|position|anchor|rotate))?)"
+ r"\s*:",
+ re.IGNORECASE,
+)
+# SVG 2 makes width/height CSS geometry properties on a <rect>, so they can
+# resize a box the checked attributes never state. Every shipped page sizes
+# its <svg> and HTML chrome with them in the stylesheet, so a <style> rule
+# with one is only reported when its selector can reach a box rect, as in
+# verify-marimekko.py; an inline style on a rect is reported outright.
+# Comments are blanked first: a browser treats `/* */` as whitespace, so
+# `rect{/**/width:300px}` is a live size rule. A subject with no type, class,
+# id or attribute (`:nth-child`, `:not(...)`) can still be that rect.
+CSS_SIZE_PROPS = ("width", "height")
+FORBIDDEN_RE = re.compile(
+ r"<(?P<tag>use|set|animate[\w-]*|foreignobject)\b",
+ re.IGNORECASE,
+)
+LINK_RE = re.compile(r"<link\b(?P<attrs>[^>]*)>", re.IGNORECASE)
+TSPAN_RE = re.compile(r"<tspan\b(?P<attrs>[^>]*)>", re.IGNORECASE)
+NONRENDER_OPEN_RE = re.compile(
+ r"<(?P<tag>defs|symbol|clipPath|mask|pattern|marker)\b[^>]*?(?P<selfclose>/?)>",
+ re.IGNORECASE,
+)
+NONRENDER_CLOSE_RE = re.compile(
+ r"</(?P<tag>defs|symbol|clipPath|mask|pattern|marker)\s*>",
+ re.IGNORECASE,
+)
+PAINT_DECL_RE = re.compile(
+ r"(?:^|[{;])\s*(?:fill|stroke)\s*:\s*([^;}{]+)",
+ re.IGNORECASE,
+)
+STROKE_DECL_RE = re.compile(r"(?:^|[{;])\s*stroke\s*:\s*([^;}{]+)", re.IGNORECASE)
+HIDE_DECL_RE = re.compile(
+ r"(?:^|[{;])\s*(opacity|fill-opacity|stroke-opacity|visibility|display)"
+ r"\s*:\s*([^;}{]+)",
+ re.IGNORECASE,
+)
+TAG_RE = re.compile(r"<[^>]+>")
+OPEN_TAG_RE = re.compile(r"<(?P<tag>[A-Za-z][\w-]*)\b(?P<attrs>[^>]*)>")
+NON_MARK_TAGS = {"text", "tspan", "title", "desc"}
+NUMBER_RE = re.compile(
+ r"[-+]?(?:\d{1,3}(?:,\d{3})+(?:\.\d+)?|\d+(?:\.\d+)?|\.\d+)(?:[eE][-+]?\d+)?"
+)
+DIGIT_RE = re.compile(r"\d")
+ATTR_RE = re.compile(
+ r"""(?P<name>[\w:-]+)\s*=\s*(?P<quote>["'])(?P<value>.*?)(?P=quote)""",
+ re.DOTALL,
+)
+DECLARES_Q1_RE = re.compile(r"\bdata-q1\s*=", re.IGNORECASE)
+TUKEY_K = 1.5
+ACCENT_RE = re.compile(
+ r"#(?:bf4520|f08a59)(?:[0-9a-f]{2})?\b|"
+ r"rgba?\(\s*191\s*,\s*69\s*,\s*32\b|"
+ r"rgba?\(\s*240\s*,\s*138\s*,\s*89\b",
+ re.IGNORECASE,
+)
+ACCENT_RGBS = ((191, 69, 32), (240, 138, 89))
+HSL_RE = re.compile(
+ r"hsla?\(\s*([-+]?[\d.]+)(deg|grad|rad|turn)?[\s,]+([\d.]+)%?[\s,]+([\d.]+)%?",
+ re.IGNORECASE,
+)
+HUE_DEGREES = {"deg": 1.0, "grad": 0.9, "rad": 180 / math.pi, "turn": 360.0}
+# Every whole-number hsl() spelling of either accent (each part rounded up
+# or down) converts to within 4.1 of it on a 0-255 channel.
+HSL_TOLERANCE = 4.5
+VAR_REF_RE = re.compile(r"var\(\s*(--[\w-]+)", re.IGNORECASE)
+CUSTOM_PROP_RE = re.compile(r"(?<![\w-])(--[\w-]+)\s*:\s*([^;{}<>\"']*)")
+COMPOUND_RE = re.compile(r"(?:\[[^\]]*\]|\([^)]*\)|[^\s>+~\[\]()])+")
+ATTR_SELECTOR_RE = re.compile(
+ r"\[\s*([\w:-]+)\s*(?:([~|^$*]?=)\s*(?:\"([^\"]*)\"|'([^']*)'|([^\s\]\"']+)))?"
+ r"\s*([a-zA-Z]?)\s*\]"
+)
+MARK_ROLES = {"box", "median", "whisker-lo", "whisker-hi", "cap"}
+
+RESIDUAL_TOLERANCE = 1.0
+VALUE_TOLERANCE = 0.001
+TICK_TOLERANCE = 6.0
+SAME_ROW_TOLERANCE = 1.0
+MIN_SERIES, MAX_SERIES = 3, 8
+MAX_OUTLIERS = 8
+
+
+class Series:
+ __slots__ = (
+ "name", "q1", "q2", "q3", "wlo", "whi", "cy", "box_x", "box_w",
+ "box_y", "box_h", "median_x", "median_x2", "median_y", "wlo_x",
+ "wlo_inner", "whi_x", "whi_inner", "whisker_y", "accent", "offset",
+ "outliers", "labels", "body_at", "body_end", "medians", "caps",
+ )
+
+ def __init__(self, **kw):
+ for key, value in kw.items():
+ setattr(self, key, value)
+
+
+class GroupMatch:
+ """One <g> element with its full body, nested groups included."""
+ __slots__ = ("_start", "_attrs", "_body", "_body_at")
+
+ def __init__(self, start: int, attrs: str, body: str, body_at: int):
+ self._start, self._attrs, self._body, self._body_at = (
+ start, attrs, body, body_at)
+
+ def start(self) -> int:
+ return self._start
+
+ def body_at(self) -> int:
+ return self._body_at
+
+ def group(self, key: str) -> str:
+ return self._attrs if key == "attrs" else self._body
+
+
+def groups_of(source: str) -> list:
+ """Every <g> in document order, matched to its own closing tag.
+
+ A non-greedy `<g>.*?</g>` stops at the first close, so a plain wrapper
+ around the series would swallow the first series and hide it.
+ """
+ events = []
+ for match in G_OPEN_RE.finditer(source):
+ events.append((match.start(), 0, match))
+ for match in G_CLOSE_RE.finditer(source):
+ events.append((match.start(), 1, match))
+ events.sort(key=lambda event: (event[0], event[1]))
+ stack, found = [], []
+ for _position, kind, match in events:
+ if kind == 0:
+ if match.group("selfclose"):
+ found.append(GroupMatch(match.start(), match.group("attrs"),
+ "", match.end()))
+ else:
+ stack.append(match)
+ elif stack:
+ opened = stack.pop()
+ found.append(GroupMatch(opened.start(), opened.group("attrs"),
+ source[opened.end():match.start()],
+ opened.end()))
+ for opened in stack:
+ found.append(GroupMatch(opened.start(), opened.group("attrs"),
+ source[opened.end():], opened.end()))
+ found.sort(key=lambda group: group.start())
+ return found
+
+
+def line_of(source: str, offset: int) -> int:
+ return source.count("\n", 0, offset) + 1
+
+
+def blank_comments(source: str) -> str:
+ return COMMENT_RE.sub(lambda m: re.sub(r"[^\n]", " ", m.group(0)), source)
+
+
+def blank_css_comments(css: str) -> str:
+ """CSS with every `/* ... */` replaced by whitespace a browser would see.
+
+ Newlines inside the comment are kept so a match still counts lines.
+ """
+ return CSS_COMMENT_RE.sub(
+ lambda found: " " + "\n" * found.group().count("\n"), css)
+
+
+def attrs_of(raw: str) -> dict:
+ found = {}
+ for match in ATTR_RE.finditer(raw):
+ name = match.group("name").lower()
+ if name not in found:
+ found[name] = html.unescape(match.group("value"))
+ return found
+
+
+def plain(body: str) -> str:
+ return html.unescape(TAG_RE.sub("", body)).strip()
+
+
+def number(value):
+ if value is None:
+ return None
+ try:
+ parsed = float(str(value).replace(",", ""))
+ except (TypeError, ValueError):
+ return None
+ return parsed if math.isfinite(parsed) else None
+
+
+def printed_number(body: str):
+ match = NUMBER_RE.search(body)
+ if match is None:
+ return None, "prints no number"
+ outside = body[:match.start()] + body[match.end():]
+ if DIGIT_RE.search(outside):
+ return None, "prints more than one numeric token"
+ value = number(match.group())
+ if value is None:
+ return None, "prints a number this checker cannot read"
+ return value, None
+
+
+def median(values: list) -> float:
+ ordered = sorted(values)
+ middle = len(ordered) // 2
+ if len(ordered) % 2:
+ return ordered[middle]
+ return (ordered[middle - 1] + ordered[middle]) / 2.0
+
+
+def fit(points: list) -> tuple:
+ slopes = [
+ (cb - ca) / (vb - va)
+ for index, (va, ca) in enumerate(points)
+ for vb, cb in points[index + 1:]
+ if vb != va
+ ]
+ if not slopes:
+ return None, None
+ slope = median(slopes)
+ return slope, median([c - slope * v for v, c in points])
+
+
+def named_text(source: str) -> str:
+ return " ".join(plain(m.group("body")) for m in NAMED_RE.finditer(source)).casefold()
+
+
+def looks_like_box_plot(path: Path, source: str) -> bool:
+ """Does this file present itself as a box plot?
+
+ Filename, accessible name, or a <g> that binds data-q1. The group
+ restriction is the treaty line — a source-wide data-q1 search is fine
+ here because no sibling binds that attribute.
+ """
+ if path.name.startswith("example-box-plot"):
+ return True
+ if DECLARES_Q1_RE.search(source):
+ for match in groups_of(source):
+ if DECLARES_Q1_RE.search(match.group("attrs")):
+ return True
+ text = named_text(source)
+ return "box plot" in text or "boxplot" in text.replace("-", " ")
+
+
+def transform_carrier(attrs: dict, sizes: bool = False):
+ if "transform" in attrs:
+ return "transform=%r" % attrs["transform"]
+ style = attrs.get("style")
+ if style is None:
+ return None
+ plain_style = blank_css_comments(style)
+ if "\\" in plain_style:
+ return "style=%r (a backslash escape)" % style
+ for found in CSS_MOVES_MARK_RE.finditer(plain_style):
+ prop = found.group("prop").lower()
+ if prop in CSS_SIZE_PROPS and not sizes:
+ continue
+ return "style=%r (the %s property)" % (style, prop)
+ return None
+
+
+def selector_reaches_box(selector: str, boxes: list) -> bool:
+ """Could this selector's subject be a box rect? Coarse on purpose.
+
+ A `rect` type selector or a `*` claims it; a subject naming any other
+ element cannot be a rect; a subject of classes, ids and attributes alone
+ reaches a box when some box rect carries one of them. A subject with
+ none of those (`:nth-child`, a bare `:not(...)`) can still be a rect, so
+ it reaches one too. Misreads err towards a finding.
+ """
+ for alternative in selector.split(","):
+ if "\\" in alternative or re.search(r"\brect\b|\*", alternative, re.IGNORECASE):
+ return True
+ compounds = [part for part in re.split(r"[\s>+~]+", alternative.strip()) if part]
+ if not compounds:
+ continue
+ subject = re.sub(r"::?[\w-]+(?:\([^)]*\))?", "", compounds[-1])
+ if re.match(r"[A-Za-z]", subject):
+ continue
+ classes = set(re.findall(r"\.([\w-]+)", subject))
+ ids = set(re.findall(r"#([\w-]+)", subject))
+ names = {name.lower() for name in re.findall(r"\[\s*([\w-]+)", subject)}
+ if not classes and not ids and not names:
+ return True
+ for attrs in boxes:
+ if (classes & set(attrs.get("class", "").split())
+ or attrs.get("id") in ids
+ or names & set(attrs)):
+ return True
+ return False
+
+
+def selector_has_escape(css: str) -> bool:
+ return any("\\" in chunk.group(1) for chunk in re.finditer(r"([^{}]+)\{", css))
+
+
+def css_moves_mark(css: str, boxes: list):
+ css = blank_css_comments(css)
+ for found in CSS_MOVES_MARK_RE.finditer(css):
+ if found.group("prop").lower() not in CSS_SIZE_PROPS:
+ return found
+ opened = css.rfind("{", 0, found.start("prop"))
+ if opened < 0:
+ continue
+ previous = max(css.rfind("}", 0, opened), css.rfind("{", 0, opened))
+ if selector_reaches_box(css[previous + 1:opened], boxes):
+ return found
+ return None
+
+
+def transformed_spans(source: str) -> list:
+ events = []
+ for match in GROUP_OPEN_RE.finditer(source):
+ if match.group("selfclose"):
+ continue
+ attrs = attrs_of(match.group("attrs"))
+ how = None
+ if "transform" in attrs:
+ how = "an ancestor <g>/<svg> transform"
+ elif transform_carrier(attrs) is not None:
+ how = "an ancestor <g>/<svg> style transform"
+ events.append((match.start(), 0, how))
+ for match in GROUP_CLOSE_RE.finditer(source):
+ events.append((match.start(), 1, None))
+ events.sort(key=lambda event: (event[0], event[1]))
+ stack, spans = [], []
+ for position, kind, how in events:
+ if kind == 0:
+ stack.append((position, how))
+ elif stack:
+ start, was_transformed = stack.pop()
+ if was_transformed:
+ spans.append((start, position, was_transformed))
+ for start, was_transformed in stack:
+ if was_transformed:
+ spans.append((start, len(source), was_transformed))
+ return spans
+
+
+def check_transforms(source: str, findings: list, name: str) -> None:
+ boxes = [attrs for attrs in (attrs_of(m.group("attrs"))
+ for m in RECT_RE.finditer(source))
+ if attrs.get("data-role") == "box"]
+ for match in STYLE_RE.finditer(source):
+ css = blank_css_comments(match.group("body"))
+ where = "%s:%d" % (name, line_of(source, match.start()))
+ if selector_has_escape(css):
+ findings.append(
+ "%s: a <style> selector contains a backslash escape — "
+ "an escaped selector can rename the element a size rule reaches"
+ % where
+ )
+ elif css_moves_mark(css, boxes) is not None:
+ findings.append(
+ "%s: a <style> rule positions a mark with CSS "
+ "(transform/translate/rotate/scale, a geometry or box-size "
+ "property, or a motion path) — bake the offset into the attributes; a "
+ "partial transform stack is worse than an honest refusal"
+ % where
+ )
+ spans = transformed_spans(source)
+ rects = list(RECT_RE.finditer(source))
+ tagged = list(CIRCLE_RE.finditer(source)) + rects
+ tagged += list(LINE_RE.finditer(source)) + list(TEXT_RE.finditer(source))
+ tagged += groups_of(source)
+ for match in tagged:
+ attrs = attrs_of(match.group("attrs"))
+ how = transform_carrier(attrs, sizes=match in rects)
+ if how is not None:
+ findings.append(
+ "%s:%d: %s positions a mark — the checker reads raw "
+ "coordinates, so anything applied afterwards invalidates "
+ "the check that passed. Bake the offset into the attributes"
+ % (name, line_of(source, match.start()), how)
+ )
+ continue
+ for start, end, ancestor in spans:
+ if start < match.start() < end:
+ findings.append(
+ "%s:%d: %s positions a mark — the checker reads raw "
+ "coordinates, so anything applied afterwards invalidates "
+ "the check that passed. Bake the offset into the attributes"
+ % (name, line_of(source, match.start()), ancestor)
+ )
+ break
+
+
+def first_rect(body: str, role: str):
+ for match in RECT_RE.finditer(body):
+ attrs = attrs_of(match.group("attrs"))
+ if attrs.get("data-role") == role and "stroke" in attrs:
+ return attrs, match.start()
+ return None, None
+
+
+def lines_with_role(body: str, role: str) -> list:
+ found = []
+ for match in LINE_RE.finditer(body):
+ attrs = attrs_of(match.group("attrs"))
+ if attrs.get("data-role") == role:
+ found.append(attrs)
+ return found
+
+
+def declared_paints(style: str) -> list:
+ return [match.group(1).strip()
+ for match in PAINT_DECL_RE.finditer(blank_css_comments(style))]
+
+
+NEGATION_RE = re.compile(r":not\([^()]*\)", re.IGNORECASE)
+FUNCTIONAL_PSEUDO_RE = re.compile(r":[\w-]+\(")
+
+
+def literal_accent(value: str) -> bool:
+ """Does this paint spell the accent as hex, rgb() or hsl()?"""
+ if ACCENT_RE.search(value):
+ return True
+ for found in HSL_RE.finditer(value):
+ hue, sat, light = (number(found.group(index)) for index in (1, 3, 4))
+ if None in (hue, sat, light):
+ continue
+ hue *= HUE_DEGREES[(found.group(2) or "deg").lower()]
+ rgb = [255 * part for part in colorsys.hls_to_rgb(
+ hue / 360 % 1, min(light, 100) / 100, min(sat, 100) / 100)]
+ if any(max(abs(a - b) for a, b in zip(rgb, accent)) <= HSL_TOLERANCE
+ for accent in ACCENT_RGBS):
+ return True
+ return False
+
+
+def accent_properties(source: str) -> set:
+ """Custom properties whose value is, or refers on to, the accent.
+
+ Declarations are read from the whole document, stylesheet and inline
+ style alike, with no scoping: a name set to the accent anywhere counts
+ everywhere it is used. A var() fallback is part of the value, so it is
+ read too.
+ """
+ accent, used_by = set(), {}
+ for found in CUSTOM_PROP_RE.finditer(source):
+ name, value = found.group(1), found.group(2)
+ if literal_accent(value):
+ accent.add(name)
+ for used in VAR_REF_RE.findall(value):
+ used_by.setdefault(used, []).append(name)
+ queue = list(accent)
+ while queue:
+ for name in used_by.get(queue.pop(), ()):
+ if name not in accent:
+ accent.add(name)
+ queue.append(name)
+ return accent
+
+
+def is_accent(value: str, accent_vars: set) -> bool:
+ return literal_accent(value) or any(
+ name in accent_vars for name in VAR_REF_RE.findall(value))
+
+
+def compound_requirement(compound: str):
+ """What an element must carry for one compound selector to match it.
+
+ Classes stay bare names; `#id` and `[attr]` / `[attr=value]` become
+ tokens that element_tokens() produces. Ids and values compare lowercased
+ and any operator other than `=` reads as presence, so a misread only
+ widens the match. None: the compound names nothing an element carries
+ (a type, `*`, a pseudo-class). frozenset(): not modelled, so it matches
+ every element.
+ """
+ # A negation never adds a requirement, so dropping it can only widen
+ # what the rule paints.
+ positive = NEGATION_RE.sub("", compound)
+ if FUNCTIONAL_PSEUDO_RE.search(positive):
+ # :is(), :where(), :has() and the like are not modelled. Fail
+ # closed: the paint reaches every element.
+ return frozenset()
+ bare = re.sub(r"\[[^\]]*\]", " ", positive)
+ tokens = set(re.findall(r"\.([\w-]+)", bare))
+ tokens.update("#" + name.lower() for name in re.findall(r"#([\w-]+)", bare))
+ for bracket in re.findall(r"\[[^\]]*\]", positive):
+ parsed = ATTR_SELECTOR_RE.fullmatch(bracket)
+ if parsed is None:
+ return frozenset()
+ name = parsed.group(1).lower()
+ value = next((part for part in parsed.group(3, 4, 5) if part is not None), None)
+ if parsed.group(2) == "=" and not parsed.group(6) and value is not None:
+ tokens.add("[%s=%s]" % (name, value.lower()))
+ else:
+ tokens.add("[%s]" % name)
+ return frozenset(tokens) if tokens else None
+
+
+def element_tokens(attrs: dict) -> set:
+ tokens = set(attrs.get("class", "").split())
+ if "id" in attrs:
+ tokens.add("#" + attrs["id"].lower())
+ for name, value in attrs.items():
+ tokens.update(("[%s]" % name, "[%s=%s]" % (name, value.lower())))
+ return tokens
+
+
+def class_paints(source: str, accent_vars: set) -> dict:
+ """Required tokens -> fill/stroke values from a rule that names them.
+
+ Read for paper masks; the accent check uses selector_rules(). Each key
+ is the frozenset of classes, ids and attributes one compound selector
+ requires, so `.series.focal rect` paints only under an element
+ carrying both classes and `[data-name="Auth"] rect` only under Auth.
+ `("stroke", <tokens>)` keys hold the stroke values alone.
+ """
+ found = {}
+ for match in STYLE_RE.finditer(source):
+ css = blank_css_comments(match.group("body"))
+ for rule in re.finditer(r"([^{}]+)\{([^{}]*)\}", css):
+ paints = declared_paints(rule.group(2))
+ if not paints:
+ continue
+ for alternative in rule.group(1).split(","):
+ compounds = COMPOUND_RE.findall(alternative)
+ if not compounds:
+ continue
+ subject = compounds[-1]
+ typed = re.match(r"([A-Za-z][\w-]*)", subject)
+ if typed and typed.group(1).lower() in NON_MARK_TAGS:
+ continue
+ # `.hot rect` paints the rects under whatever carries
+ # .hot, so an ancestor compound counts as well as the
+ # subject's. A compound such as `.series.focal` only matches
+ # an element that carries every class it names.
+ fills = paints
+ strokes = [value.strip() for value in STROKE_DECL_RE.findall(rule.group(2))]
+ required_sets = [required for required in map(compound_requirement, compounds)
+ if required is not None]
+ if not required_sets:
+ # Only types, `*` and pseudo-classes: an accent it sets
+ # may reach any paper mask.
+ required_sets = [frozenset()]
+ fills = [value for value in fills if is_accent(value, accent_vars)]
+ strokes = [value for value in strokes if is_accent(value, accent_vars)]
+ for required in required_sets:
+ found.setdefault(required, []).extend(fills)
+ found.setdefault(("stroke", required), []).extend(strokes)
+ return found
+
+
+# Shapes that never hold another element, so a rule painting one of them
+# can't reach a paper-mask circle or pass a stroke down to it.
+LEAF_TAGS = {"rect", "line", "path", "text", "tspan", "polygon", "polyline",
+ "ellipse", "image", "use"}
+
+
+def class_stroke_rules(source: str) -> list:
+ """Stroke rules a paper mask's ancestors may pass down.
+
+ One (required classes, on_subject, reaches_mask, strokes) entry per
+ class-bearing compound. `on_subject` marks the compound the rule paints
+ (`.outer{stroke:...}` paints the group itself, so it inherits and can be
+ overridden further down). A non-subject compound (`.hot rect`) paints
+ descendants; `reaches_mask` says whether its subject can be the mask
+ or a group between it and the ancestor (anything but a leaf shape).
+ A descendant rule on a group (`.outer g`) is kept as reaching the mask
+ without working out which group it lands on, so it fails closed.
+ """
+ rules = []
+ for match in STYLE_RE.finditer(source):
+ css = blank_css_comments(match.group("body"))
+ for rule in re.finditer(r"([^{}]+)\{([^{}]*)\}", css):
+ strokes = [value.strip().lower()
+ for value in STROKE_DECL_RE.findall(rule.group(2))]
+ if not strokes:
+ continue
+ for alternative in rule.group(1).split(","):
+ compounds = [part for part in re.split(r"[\s>+~]+", alternative.strip())
+ if part]
+ if not compounds:
+ continue
+ typed = re.match(r"([A-Za-z][\w-]*)", compounds[-1])
+ reaches_mask = not typed or typed.group(1).lower() not in LEAF_TAGS
+ for index, compound in enumerate(compounds):
+ positive = NEGATION_RE.sub("", compound)
+ if FUNCTIONAL_PSEUDO_RE.search(positive):
+ # Not modelled: fail closed, the stroke reaches the
+ # mask and nothing overrides it.
+ rules.append((frozenset(), False, True, strokes))
+ continue
+ required = frozenset(re.findall(r"\.([\w-]+)", positive))
+ if required:
+ rules.append((required, index == len(compounds) - 1,
+ reaches_mask, strokes))
+ return rules
+
+
+def matching_class_paints(attrs: dict, paints: dict, stroke: bool) -> list:
+ tokens = element_tokens(attrs)
+ values = []
+ for key, found in paints.items():
+ required = key[1] if isinstance(key, tuple) else key
+ if isinstance(key, tuple) != stroke:
+ continue
+ if required <= tokens:
+ values.extend(found)
+ return values
+
+
+def element_paints(attrs: dict, paints: dict) -> list:
+ values = [attrs[key] for key in ("fill", "stroke") if key in attrs]
+ values.extend(declared_paints(attrs.get("style", "")))
+ values.extend(matching_class_paints(attrs, paints, stroke=False))
+ return values
+
+
+def stroke_paints(attrs: dict, paints: dict) -> list:
+ """Stroke values an element states itself (attribute, style, class)."""
+ values = [attrs["stroke"]] if "stroke" in attrs else []
+ values.extend(value.strip() for value in
+ STROKE_DECL_RE.findall(blank_css_comments(attrs.get("style", ""))))
+ values.extend(matching_class_paints(attrs, paints, stroke=True))
+ return values
+
+
+def wears_accent(tag: str, attrs: dict, chain: list, accent_vars: set, rules: list) -> bool:
+ """Accent from the element's own attribute or inline style, or a <style> rule selecting it."""
+ return any(is_accent(value, accent_vars) for value in element_paints(attrs, {})) \
+ or css_matches(tag, element_tokens(attrs), chain, rules)
+
+
+def figure_paper(source: str):
+ """Fill of the full-bleed paper rect, if this figure states one."""
+ for match in RECT_RE.finditer(source):
+ attrs = attrs_of(match.group("attrs"))
+ if attrs.get("width", "").strip() != "100%":
+ continue
+ fill = attrs.get("fill", "").strip().lower()
+ if fill.startswith("#"):
+ return fill
+ return None
+
+
+def hides(attrs: dict, opacities=("opacity", "fill-opacity", "stroke-opacity")) -> bool:
+ if "hidden" in attrs:
+ return True
+ if attrs.get("visibility", "").strip().lower() in {"hidden", "collapse"}:
+ return True
+ if attrs.get("display", "").strip().lower() == "none":
+ return True
+ for key in opacities:
+ raw = attrs.get(key)
+ if raw is None:
+ continue
+ value = number(str(raw).strip().rstrip("%"))
+ if value is not None and value <= 0:
+ return True
+ return declares_hidden(blank_css_comments(attrs.get("style", "")), opacities)
+
+
+def declares_hidden(css: str, opacities) -> bool:
+ """Does this declaration block set display:none, visibility:hidden or an opacity of 0?"""
+ for match in HIDE_DECL_RE.finditer(css):
+ prop = match.group(1).lower()
+ raw = match.group(2).split("!")[0].strip().lower()
+ if prop == "display" and raw == "none":
+ return True
+ if prop == "visibility" and raw in {"hidden", "collapse"}:
+ return True
+ if prop in opacities:
+ value = number(raw.rstrip("%"))
+ if value is not None and value <= 0:
+ return True
+ return False
+
+
+VOID_TAGS = {"area", "base", "br", "col", "embed", "hr", "img", "input", "link",
+ "meta", "source", "track", "wbr"}
+ANY_TAG_RE = re.compile(
+ r"<(?P<close>/?)(?P<tag>[A-Za-z][\w:-]*)\b(?P<attrs>[^>]*?)(?P<selfclose>/?)>")
+
+
+def svg_ancestors(source: str) -> list:
+ """(tag, attrs) for the first <svg> and every element open around it."""
+ found = re.search(r"<svg\b", source, re.IGNORECASE)
+ if found is None:
+ return []
+ stack = []
+ for tag in ANY_TAG_RE.finditer(source, 0, found.start()):
+ name = tag.group("tag").lower()
+ if tag.group("close"):
+ if any(open_name == name for open_name, _attrs in stack):
+ while stack.pop()[0] != name:
+ pass
+ elif not tag.group("selfclose") and name not in VOID_TAGS:
+ stack.append((name, attrs_of(tag.group("attrs"))))
+ svg = ANY_TAG_RE.match(source, found.start())
+ return stack + [("svg", attrs_of(svg.group("attrs")) if svg else {})]
+
+
+def compound_kind(compound: str) -> tuple:
+ """(type or None, required tokens) for one compound selector."""
+ typed = re.match(r"[A-Za-z][\w-]*", compound)
+ return (typed.group().lower() if typed else None,
+ compound_requirement(compound) or frozenset())
+
+
+def selector_rules(source: str, wanted) -> list:
+ """(type, subject tokens, ancestors) for each selector of a rule `wanted` accepts.
+
+ The subject compound must match the element itself, by type when it
+ names one. `ancestors` holds (type, tokens) for every other compound,
+ outermost first, and they must match the element's strict ancestors in
+ that order. `>` reads as any ancestor and a sibling combinator drops
+ them; both only widen the match. A subject naming only a type, `*` or
+ pseudo-classes matches every element of that type.
+ """
+ rules = []
+ for match in STYLE_RE.finditer(source):
+ css = blank_css_comments(match.group("body"))
+ for rule in re.finditer(r"([^{}]+)\{([^{}]*)\}", css):
+ if not wanted(rule.group(2)):
+ continue
+ for alternative in rule.group(1).split(","):
+ kinds = [compound_kind(compound) for compound in COMPOUND_RE.findall(alternative)]
+ if not kinds:
+ continue
+ siblings = re.search(r"[+~]", re.sub(r"\[[^\]]*\]|\([^)]*\)", "", alternative))
+ ancestors = [] if siblings else [
+ kind for kind in kinds[:-1] if kind != (None, frozenset())]
+ rules.append(kinds[-1] + (ancestors,))
+ return rules
+
+
+def css_matches(tag: str, tokens: set, chain: list, rules: list) -> bool:
+ """Does a rule select this element? `chain`: (tag, tokens) of its strict ancestors, outermost first."""
+ for kind, subject, ancestors in rules:
+ if kind not in (None, tag) or not subject <= tokens:
+ continue
+ # Nearest matching ancestor first, walking outwards, which finds a
+ # match for a chain of descendant combinators whenever one exists.
+ index = len(chain)
+ for need_kind, need in reversed(ancestors):
+ while index:
+ index -= 1
+ if need_kind in (None, chain[index][0]) and need <= chain[index][1]:
+ break
+ else:
+ break
+ else:
+ return True
+ return False
+
+
+def positioned_tspan(body: str) -> bool:
+ for match in TSPAN_RE.finditer(body):
+ attrs = attrs_of(match.group("attrs"))
+ if any(key in attrs for key in ("x", "y", "dx", "dy")):
+ return True
+ return False
+
+
+def font_stylesheet(href: str) -> bool:
+ return href.startswith("https://fonts.googleapis.com/")
+
+
+def nonrendering_spans(source: str) -> list:
+ events = [(m.start(), 0, m.group("tag").lower())
+ for m in NONRENDER_OPEN_RE.finditer(source)
+ if not m.group("selfclose")]
+ events += [(m.start(), 1, m.group("tag").lower())
+ for m in NONRENDER_CLOSE_RE.finditer(source)]
+ events.sort(key=lambda event: (event[0], event[1]))
+ stack, spans = [], []
+ for position, kind, tag in events:
+ if kind == 0:
+ stack.append((tag, position))
+ elif stack and stack[-1][0] == tag:
+ spans.append((stack.pop()[1], position))
+ elif stack:
+ stack.pop()
+ return spans
+
+
+def axis_left(items: list, source: str) -> float:
+ lefts = []
+ for item in items:
+ lefts.extend((item.box_x, item.wlo_x))
+ for match in TEXT_RE.finditer(source):
+ attrs = attrs_of(match.group("attrs"))
+ if attrs.get("data-tick", "").strip().casefold() != "x":
+ continue
+ tick_x = number(attrs.get("x"))
+ if tick_x is not None:
+ lefts.append(tick_x)
+ return min(lefts) if lefts else 0.0
+
+
+def view_x_span(source: str) -> tuple:
+ match = re.search(r"<svg\b(?P<attrs>[^>]*)>", source, re.IGNORECASE)
+ raw = "0 0 1000 500"
+ if match is not None:
+ raw = attrs_of(match.group("attrs")).get("viewbox", raw)
+ parts = [number(part) for part in raw.replace(",", " ").split()[:4]]
+ if len(parts) == 4 and all(part is not None for part in parts) and parts[2] > 0:
+ return parts[0], parts[0] + parts[2]
+ return 0.0, 1000.0
+
+
+def parse_series(source: str, findings: list, name: str) -> list:
+ accent_vars = accent_properties(source)
+ paints = class_paints(source, accent_vars)
+ stroke_rules = class_stroke_rules(source)
+ paper = figure_paper(source)
+ hidden = nonrendering_spans(source)
+ series = []
+ groups = groups_of(source)
+ # fail closed: no cascade, so a later rule that restores visibility does not clear a hide
+ hide_rules = selector_rules(source, lambda css: declares_hidden(css, ("opacity",)))
+ accent_rules = selector_rules(source, lambda css: any(
+ is_accent(value, accent_vars) for value in declared_paints(css)))
+ page = svg_ancestors(source)
+ outer = [(tag, element_tokens(attrs)) for tag, attrs in page]
+ # Hiding or painting the <svg> or a page element around it reaches every
+ # series. Only whole-element opacity counts: a box with fill-opacity 0
+ # still draws its stroke.
+ page_hidden = any(hides(attrs, ("opacity",))
+ or css_matches(tag, outer[index][1], outer[:index], hide_rules)
+ for index, (tag, attrs) in enumerate(page))
+ page_accent = any(wears_accent(tag, attrs, outer[:index], accent_vars, accent_rules)
+ for index, (tag, attrs) in enumerate(page))
+ # Each group's strict ancestors, outermost first, and whether it or one
+ # of them wears the accent, which every series inside inherits.
+ around, accented, stack = {}, {}, []
+ for group in groups:
+ while stack and stack[-1][0] <= group.start():
+ stack.pop()
+ gattrs = attrs_of(group.group("attrs"))
+ around[group.start()] = outer + [entry for _end, entry, _accent in stack]
+ accented[group.start()] = (stack[-1][2] if stack else page_accent) or wears_accent(
+ "g", gattrs, around[group.start()], accent_vars, accent_rules)
+ stack.append((group.body_at() + len(group.group("body")),
+ ("g", element_tokens(gattrs)), accented[group.start()]))
+ # Groups that stop everything inside them drawing.
+ hiding = [(group.body_at(), group.body_at() + len(group.group("body")))
+ for group in groups
+ if hides(attrs_of(group.group("attrs")), ("opacity",))
+ or css_matches("g", element_tokens(attrs_of(group.group("attrs"))),
+ around[group.start()], hide_rules)]
+ svgs = [attrs_of(m.group("attrs")) for m in GROUP_OPEN_RE.finditer(source)
+ if m.group(0)[:4].lower() == "<svg"]
+ for match in groups:
+ raw = match.group("attrs")
+ if not DECLARES_Q1_RE.search(raw):
+ continue
+ attrs = attrs_of(raw)
+ where = "%s:%d" % (name, line_of(source, match.start()))
+ keys = ("data-name", "data-q1", "data-q2", "data-q3", "data-wlo",
+ "data-whi")
+ missing = [key for key in keys if key not in attrs]
+ if missing:
+ findings.append(
+ "%s: a box-plot series is missing %s — each series declares "
+ "its name and the five-number summary"
+ % (where, ", ".join(missing))
+ )
+ continue
+ parsed = {
+ "q1": number(attrs["data-q1"]),
+ "q2": number(attrs["data-q2"]),
+ "q3": number(attrs["data-q3"]),
+ "wlo": number(attrs["data-wlo"]),
+ "whi": number(attrs["data-whi"]),
+ }
+ if any(value is None for value in parsed.values()):
+ findings.append(
+ "%s: series %r has a five-number value that is not a finite "
+ "number — cannot verify its geometry"
+ % (where, attrs["data-name"])
+ )
+ continue
+ body = match.group("body")
+ body_at = match.body_at()
+ box, _ = first_rect(body, "box")
+ median_lines = lines_with_role(body, "median")
+ whisker_lines = lines_with_role(body, "whisker-lo")
+ whisker_hi_lines = lines_with_role(body, "whisker-hi")
+ if box is None or not median_lines or not whisker_lines \
+ or not whisker_hi_lines:
+ findings.append(
+ "%s: series %r is missing a stroked data-role=box rect, a "
+ "data-role=median line, or a whisker-lo/whisker-hi pair"
+ % (where, attrs["data-name"])
+ )
+ continue
+ boxes = [m for m in RECT_RE.finditer(body)
+ if attrs_of(m.group("attrs")).get("data-role") == "box"]
+ for role, count in (("box", len(boxes)),
+ ("whisker-lo", len(whisker_lines)),
+ ("whisker-hi", len(whisker_hi_lines))):
+ if count > 1:
+ findings.append(
+ "%s: series %r draws %d data-role=%s marks; a series has "
+ "exactly one, and an extra mark shows a value the checker "
+ "never reads" % (where, attrs["data-name"], count, role)
+ )
+ drawn = True
+ body_end = body_at + len(body)
+ series_chain = around[match.start()] + [("g", element_tokens(attrs))]
+ inner = [(group.body_at(), group.body_at() + len(group.group("body")),
+ ("g", element_tokens(attrs_of(group.group("attrs")))))
+ for group in groups if body_at <= group.start() < body_end]
+
+ def chain_at(offset: int) -> list:
+ """Strict ancestors of the element starting at `offset`, outermost first."""
+ return series_chain + [entry for start, end, entry in inner if start <= offset < end]
+
+ for mark in OPEN_TAG_RE.finditer(body):
+ mattrs = attrs_of(mark.group("attrs"))
+ if not ({"data-role", "data-outlier", "data-name"} & set(mattrs)):
+ continue
+ # check_structure reports a series whose own group is hidden.
+ if inside_span(body_at + mark.start(), hidden) \
+ and not inside_span(match.start(), hidden):
+ findings.append(
+ "%s:%d: series %r has a bound <%s> inside a non-rendering "
+ "container, so the checker reads a mark that is never drawn"
+ % (name, line_of(source, body_at + mark.start()),
+ attrs["data-name"], mark.group("tag").lower())
+ )
+ # The series group's own span is in `hiding` when it hides itself.
+ at = body_at + mark.start()
+ if drawn and {"data-role", "data-outlier"} & set(mattrs) and (
+ page_hidden or hides(mattrs, ("opacity",))
+ or inside_span(at, hiding)
+ or css_matches(mark.group("tag").lower(), element_tokens(mattrs),
+ chain_at(at), hide_rules)):
+ drawn = False
+ findings.append(
+ "%s:%d: series %r has a bound <%s> hidden by display, "
+ "visibility or opacity (an attribute, inline style or "
+ "<style> rule) on the mark or an element around it, so the "
+ "checker reads a mark that is never drawn"
+ % (name, line_of(source, body_at + mark.start()),
+ attrs["data-name"], mark.group("tag").lower())
+ )
+ whisker_lo, whisker_hi = whisker_lines[0], whisker_hi_lines[0]
+ medians = []
+ bad_coord = False
+ for median_line in median_lines:
+ med_nums = [number(median_line.get(key)) for key in ("x1", "y1", "x2", "y2")]
+ if any(value is None for value in med_nums):
+ bad_coord = True
+ break
+ medians.append(tuple(med_nums))
+ box_nums = [number(box.get(key)) for key in ("x", "y", "width", "height")]
+ lo_nums = [number(whisker_lo.get(key)) for key in ("x1", "y1", "x2", "y2")]
+ hi_nums = [number(whisker_hi.get(key)) for key in ("x1", "y1", "x2", "y2")]
+ if bad_coord or any(value is None for value in box_nums + lo_nums + hi_nums):
+ findings.append(
+ "%s: series %r has a coordinate that is not a finite number"
+ % (where, attrs["data-name"])
+ )
+ continue
+ caps = []
+ for cap in lines_with_role(body, "cap"):
+ cap_xs = [number(cap.get(key)) for key in ("x1", "y1", "x2", "y2")]
+ if any(value is None for value in cap_xs):
+ findings.append(
+ "%s: series %r has a cap coordinate that is not a finite "
+ "number" % (where, attrs["data-name"])
+ )
+ continue
+ caps.append(tuple(cap_xs))
+ cy = box_nums[1] + box_nums[3] / 2.0
+ # Paint inherits, so the series <g> itself, any group or page element
+ # around it and any nested group count, and so does any shape the
+ # series draws, not only the rect/line/circle marks bound above.
+ accent = accented[match.start()] or any(
+ wears_accent(mark.group("tag").lower(), attrs_of(mark.group("attrs")),
+ chain_at(body_at + mark.start()), accent_vars, accent_rules)
+ for mark in OPEN_TAG_RE.finditer(body)
+ if mark.group("tag").lower() not in NON_MARK_TAGS
+ )
+ outliers = []
+ unbound = []
+ for circle in CIRCLE_RE.finditer(body):
+ cattrs = attrs_of(circle.group("attrs"))
+ if "data-outlier" not in cattrs:
+ unbound.append((cattrs, body_at + circle.start()))
+ continue
+ if "data-x" not in cattrs:
+ findings.append(
+ "%s: an outlier on %r declares data-outlier but no "
+ "data-x — a visible mark with no bound value is never "
+ "checked" % (where, attrs["data-name"])
+ )
+ continue
+ cx = number(cattrs.get("cx"))
+ ccy = number(cattrs.get("cy"))
+ value = number(cattrs.get("data-x"))
+ if None in (cx, ccy, value):
+ findings.append(
+ "%s: an outlier on %r has a value or coordinate that is "
+ "not a finite number"
+ % (where, attrs["data-name"])
+ )
+ continue
+ radius = number(cattrs.get("r"))
+ if radius is None or radius <= 0:
+ findings.append(
+ "%s: an outlier on %r has no positive radius — a dot "
+ "with r missing or 0 is never drawn"
+ % (where, attrs["data-name"])
+ )
+ continue
+ outliers.append((value, cx, ccy))
+ # Paint inherits: a mask that states no stroke of its own takes the
+ # stroke of the nearest ancestor that sets one (the <svg> itself, a
+ # wrapper, the series group, a group inside it), so an inner
+ # stroke="none" overrides an outer stroke. Only the circle's own
+ # ancestors count: a sibling group's stroke never reaches it.
+ # A class rule counts as the ancestor's own stroke only when the
+ # ancestor is the rule's subject (`.outer{stroke:...}`). A rule that
+ # paints descendants (`.hot circle`, `.hot g`) is treated as reaching
+ # the mask directly, so no inner group overrides it; one whose subject
+ # is a leaf shape (`.hot rect`) never reaches the mask at all.
+ for cattrs, at in unbound:
+ ancestors = [attrs_of(g.group("attrs")) for g in groups
+ if g.body_at() <= at < g.body_at() + len(g.group("body"))]
+ inherited, direct = set(), set()
+ for holder in svgs + ancestors:
+ classes = set(holder.get("class", "").split())
+ stated = {value.strip().lower()
+ for value in stroke_paints(holder, {})}
+ for required, on_subject, reaches_mask, strokes in stroke_rules:
+ if not required <= classes:
+ continue
+ if on_subject:
+ stated.update(strokes)
+ elif reaches_mask:
+ direct.update(strokes)
+ if stated:
+ inherited = stated
+ inherited |= direct
+ cx = number(cattrs.get("cx"))
+ ccy = number(cattrs.get("cy"))
+ fill = cattrs.get("fill", "").strip().lower()
+ painted = {value.strip().lower()
+ for value in element_paints(cattrs, paints)}
+ if not stroke_paints(cattrs, paints):
+ painted |= inherited
+ colocated = (
+ cx is not None and ccy is not None
+ and any(abs(cx - ox) <= 0.5 and abs(ccy - oy) <= 0.5
+ for _value, ox, oy in outliers)
+ )
+ if not (colocated and paper is not None and fill == paper
+ and painted <= {paper, "none"}):
+ findings.append(
+ "%s: series %r has an unbound circle — a circle without "
+ "data-outlier must be a paper mask on a bound outlier"
+ % (where, attrs["data-name"])
+ )
+ labels = []
+ for text in TEXT_RE.finditer(body):
+ tattrs = attrs_of(text.group("attrs"))
+ if "data-name" not in tattrs:
+ continue
+ labels.append((tattrs["data-name"], plain(text.group("body")),
+ number(tattrs.get("x")), number(tattrs.get("y"))))
+ if "dx" in tattrs or "dy" in tattrs:
+ findings.append(
+ "%s: series %r bound label carries dx/dy — a shift the "
+ "checked x/y attributes never state"
+ % (where, attrs["data-name"])
+ )
+ if positioned_tspan(text.group("body")):
+ findings.append(
+ "%s: series %r bound label has a positioned <tspan> — "
+ "the visible name is not where x/y say it is"
+ % (where, attrs["data-name"])
+ )
+ if hides(tattrs) or any(
+ hides(attrs_of(tspan.group("attrs")))
+ for tspan in TSPAN_RE.finditer(text.group("body"))):
+ findings.append(
+ "%s: series %r hides its bound label — the name the "
+ "checker reads is not the name a reader sees"
+ % (where, attrs["data-name"])
+ )
+ med_nums = medians[0]
+ series.append(Series(
+ name=attrs["data-name"],
+ q1=parsed["q1"], q2=parsed["q2"], q3=parsed["q3"],
+ wlo=parsed["wlo"], whi=parsed["whi"],
+ cy=cy,
+ box_x=box_nums[0], box_w=box_nums[2],
+ box_y=box_nums[1], box_h=box_nums[3],
+ median_x=med_nums[0], median_x2=med_nums[2],
+ median_y=(med_nums[1], med_nums[3]),
+ wlo_x=min(lo_nums[0], lo_nums[2]),
+ wlo_inner=max(lo_nums[0], lo_nums[2]),
+ whi_x=max(hi_nums[0], hi_nums[2]),
+ whi_inner=min(hi_nums[0], hi_nums[2]),
+ whisker_y=(lo_nums[1], lo_nums[3], hi_nums[1], hi_nums[3]),
+ accent=accent,
+ offset=match.start(),
+ outliers=outliers,
+ labels=labels,
+ body_at=body_at,
+ body_end=body_at + len(body),
+ medians=medians,
+ caps=caps,
+ ))
+ return series
+
+
+def check_scale(items: list, findings: list, source: str, name: str):
+ points = []
+ for item in items:
+ points.extend([
+ (item.q1, item.box_x),
+ (item.q3, item.box_x + item.box_w),
+ (item.q2, item.median_x),
+ (item.wlo, item.wlo_x),
+ (item.whi, item.whi_x),
+ ])
+ for value, cx, _cy in item.outliers:
+ points.append((value, cx))
+ distinct = {(v, x) for v, x in points}
+ if len({v for v, _x in distinct}) < 2:
+ findings.append(
+ "%s: every declared value is the same — a box plot needs a "
+ "finite nonzero value axis" % name
+ )
+ return None
+ slope, intercept = fit(list(distinct))
+ if slope is None or abs(slope) < 1e-9:
+ findings.append(
+ "%s: the value axis is not a finite nonzero linear scale"
+ % name
+ )
+ return None
+ # Leave-one-out: dropping any one point must still recover this slope
+ # within 5%, so one dishonest mark cannot set the line it is judged on.
+ if len(distinct) >= 3:
+ for skip in distinct:
+ rest = [point for point in distinct if point != skip]
+ other_slope, _ = fit(rest)
+ if other_slope is None:
+ continue
+ if abs(other_slope - slope) > 0.05 * abs(slope):
+ findings.append(
+ "%s: the shared value scale is unstable — leaving out "
+ "value %g moves the slope from %g to %g. One mark is "
+ "setting the line it is measured against"
+ % (name, skip[0], slope, other_slope)
+ )
+ break
+
+ def at(value: float) -> float:
+ return slope * value + intercept
+
+ for item in items:
+ where = "%s:%d" % (name, source.count("\n", 0, item.offset) + 1)
+ median_drawn = max((item.median_x, item.median_x2),
+ key=lambda drawn: abs(drawn - at(item.q2)))
+ checks = [
+ ("q1", item.q1, item.box_x, "the box's left edge"),
+ ("q3", item.q3, item.box_x + item.box_w, "the box's right edge"),
+ ("q2", item.q2, median_drawn, "the median line"),
+ ("wlo", item.wlo, item.wlo_x, "the low whisker"),
+ ("q1", item.q1, item.wlo_inner, "the low whisker's box end"),
+ ("whi", item.whi, item.whi_x, "the high whisker"),
+ ("q3", item.q3, item.whi_inner, "the high whisker's box end"),
+ ]
+ for label, value, drawn, role in checks:
+ expected = at(value)
+ if abs(drawn - expected) > RESIDUAL_TOLERANCE:
+ findings.append(
+ "%s: series %r %s is drawn at x=%g, but its declared "
+ "%s=%g sits at x=%g on the shared scale — move the "
+ "geometry, never the number"
+ % (where, item.name, role, drawn, label, value, expected)
+ )
+ for x1, _y1, x2, _y2 in item.medians[1:]:
+ expected = at(item.q2)
+ for drawn in (x1, x2):
+ if abs(drawn - expected) > RESIDUAL_TOLERANCE:
+ findings.append(
+ "%s: series %r the median line is drawn at x=%g, but "
+ "its declared q2=%g sits at x=%g on the shared scale "
+ "— move the geometry, never the number"
+ % (where, item.name, drawn, item.q2, expected)
+ )
+ break
+ if abs(item.box_w - abs(at(item.q3) - at(item.q1))) > RESIDUAL_TOLERANCE:
+ findings.append(
+ "%s: series %r box width is %g, but q3−q1 spans %gpx on the "
+ "shared scale — width encodes the IQR"
+ % (where, item.name, item.box_w,
+ abs(at(item.q3) - at(item.q1)))
+ )
+ iqr = item.q3 - item.q1
+ fence_lo, fence_hi = item.q1 - TUKEY_K * iqr, item.q3 + TUKEY_K * iqr
+ for value, cx, ccy in item.outliers:
+ expected = at(value)
+ if abs(cx - expected) > RESIDUAL_TOLERANCE:
+ findings.append(
+ "%s: series %r outlier %g is drawn at x=%g, but the "
+ "shared scale puts it at x=%g"
+ % (where, item.name, value, cx, expected)
+ )
+ if abs(ccy - item.cy) > SAME_ROW_TOLERANCE:
+ findings.append(
+ "%s: series %r outlier %g sits at y=%g, off the series "
+ "row y=%g — the category axis is a label rail"
+ % (where, item.name, value, ccy, item.cy)
+ )
+ if item.wlo - VALUE_TOLERANCE <= value <= item.whi + VALUE_TOLERANCE:
+ findings.append(
+ "%s: series %r outlier %g sits inside the whiskers "
+ "[%g, %g] — an outlier is strictly outside the fence"
+ % (where, item.name, value, item.wlo, item.whi)
+ )
+ elif fence_lo - VALUE_TOLERANCE <= value <= fence_hi + VALUE_TOLERANCE:
+ findings.append(
+ "%s: series %r outlier %g sits inside the Tukey fences "
+ "[%g, %g] (q1 − 1.5·IQR, q3 + 1.5·IQR) — it is an inlier, "
+ "and the whisker should reach it"
+ % (where, item.name, value, fence_lo, fence_hi)
+ )
+ return (slope, intercept, at)
+
+
+def check_focal(items: list, findings: list, name: str) -> None:
+ accents = [item for item in items if item.accent]
+ if len(accents) > 1:
+ findings.append(
+ "%s: %d series wear the accent (a box, underlay, median, "
+ "whisker, cap or outlier) — a box plot has at most "
+ "one focal series" % (name, len(accents))
+ )
+
+
+def check_shapes(items: list, findings: list, source: str, name: str) -> None:
+ """The perpendicular half of the geometry: the scale test reads only x."""
+ for item in items:
+ where = "%s:%d" % (name, line_of(source, item.offset))
+ top, bottom = item.box_y, item.box_y + item.box_h
+ for _x1, y1, _x2, y2 in item.medians:
+ if abs(min(y1, y2) - top) > SAME_ROW_TOLERANCE \
+ or abs(max(y1, y2) - bottom) > SAME_ROW_TOLERANCE:
+ findings.append(
+ "%s: series %r median runs y=%g..%g, but the box spans "
+ "y=%g..%g — the median crosses the box from edge to edge"
+ % (where, item.name, min(y1, y2), max(y1, y2), top, bottom)
+ )
+ ends = (item.wlo_x, item.whi_x)
+ for x1, y1, x2, y2 in item.caps:
+ if not any(abs(x1 - end) <= RESIDUAL_TOLERANCE
+ and abs(x2 - end) <= RESIDUAL_TOLERANCE for end in ends):
+ findings.append(
+ "%s: series %r cap is drawn at x=%g, but the whiskers "
+ "end at x=%g and x=%g — a cap marks a whisker's end"
+ % (where, item.name, x1, item.wlo_x, item.whi_x)
+ )
+ low, high = min(y1, y2), max(y1, y2)
+ if not (low - SAME_ROW_TOLERANCE <= item.cy <= high + SAME_ROW_TOLERANCE
+ and low >= top - SAME_ROW_TOLERANCE
+ and high <= bottom + SAME_ROW_TOLERANCE):
+ findings.append(
+ "%s: series %r cap runs y=%g..%g, off the whisker at "
+ "y=%g inside the box's rows y=%g..%g — a cap crosses its "
+ "whisker end" % (where, item.name, low, high, item.cy,
+ top, bottom)
+ )
+ if any(abs(y - item.cy) > SAME_ROW_TOLERANCE for y in item.whisker_y):
+ findings.append(
+ "%s: series %r has a whisker endpoint off the row centre "
+ "y=%g — whiskers are horizontal through the middle of the box"
+ % (where, item.name, item.cy)
+ )
+ iqr = item.q3 - item.q1
+ fence_lo, fence_hi = item.q1 - TUKEY_K * iqr, item.q3 + TUKEY_K * iqr
+ if item.wlo < fence_lo - VALUE_TOLERANCE or item.whi > fence_hi + VALUE_TOLERANCE:
+ findings.append(
+ "%s: series %r whiskers [%g, %g] reach past the Tukey fences "
+ "[%g, %g] — a value past the fence is an outlier, not the "
+ "whisker end" % (where, item.name, item.wlo, item.whi,
+ fence_lo, fence_hi)
+ )
+
+
+def check_labels(items: list, findings: list, source: str, name: str) -> None:
+ left = axis_left(items, source)
+ view_lo, view_hi = view_x_span(source)
+ xs = [label[2] for item in items if len(item.labels) == 1
+ for label in (item.labels[0],) if label[2] is not None]
+ rail = median(xs) if xs else None
+ for item in items:
+ where = "%s:%d" % (name, line_of(source, item.offset))
+ if len(item.labels) != 1:
+ findings.append(
+ "%s: series %r has %d bound category labels (<text data-name>) "
+ "— each series names itself with exactly one"
+ % (where, item.name, len(item.labels))
+ )
+ continue
+ bound, shown, x, y = item.labels[0]
+ if bound.strip() != item.name.strip() or shown != item.name.strip():
+ findings.append(
+ "%s: series %r is labelled data-name=%r printing %r — the "
+ "visible label must name the series it sits beside"
+ % (where, item.name, bound, shown)
+ )
+ if y is None or abs(y - item.cy) > item.box_h / 2.0:
+ findings.append(
+ "%s: series %r label sits at y=%s, off its row at y=%g"
+ % (where, item.name, "?" if y is None else "%g" % y, item.cy)
+ )
+ off_rail = (
+ x is None or x < view_lo - 0.5 or x > view_hi + 0.5
+ or x >= left - 0.5
+ or (rail is not None and abs(x - rail) > 1.0)
+ )
+ if off_rail:
+ findings.append(
+ "%s: series %r label sits at x=%s, off the label rail "
+ "(the category gutter left of the value axis at x=%g)"
+ % (where, item.name, "?" if x is None else "%g" % x, left)
+ )
+
+
+def check_names(items: list, findings: list, name: str) -> None:
+ seen = {}
+ for item in items:
+ key = item.name.strip()
+ if not key:
+ findings.append(
+ "%s: a series has an empty data-name — identity is a map key"
+ % name
+ )
+ continue
+ if key in seen:
+ findings.append(
+ "%s: two series share data-name=%r — a name that identifies "
+ "two marks identifies neither" % (name, key)
+ )
+ seen[key] = item
+ total_outliers = sum(len(item.outliers) for item in items)
+ if total_outliers > MAX_OUTLIERS:
+ findings.append(
+ "%s: %d outliers against a budget of %d — past that the tail is "
+ "a list, not a story" % (name, total_outliers, MAX_OUTLIERS)
+ )
+
+
+def check_ticks(scale, source: str, findings: list, name: str) -> None:
+ if scale is None:
+ return
+ _slope, _intercept, at = scale
+ ticks = []
+ for match in TEXT_RE.finditer(source):
+ attrs = attrs_of(match.group("attrs"))
+ if "data-tick" not in attrs:
+ continue
+ axis = attrs.get("data-tick", "").strip().casefold()
+ if axis != "x":
+ findings.append(
+ "%s:%d: a tick label has data-tick=%r — a box plot has one "
+ "value axis (data-tick=\"x\"); the category axis is a label "
+ "rail and has no scale to tick"
+ % (name, line_of(source, match.start()), attrs.get("data-tick"))
+ )
+ continue
+ declared = number(attrs.get("data-value"))
+ x = number(attrs.get("x"))
+ shown, reason = printed_number(plain(match.group("body")))
+ if declared is None or x is None:
+ findings.append(
+ "%s:%d: a value-axis tick is missing a finite data-value or x"
+ % (name, line_of(source, match.start()))
+ )
+ continue
+ if shown is None:
+ findings.append(
+ "%s:%d: a value-axis tick %s"
+ % (name, line_of(source, match.start()), reason)
+ )
+ continue
+ if abs(shown - declared) > VALUE_TOLERANCE:
+ findings.append(
+ "%s:%d: a tick declares data-value=%g but prints %g"
+ % (name, line_of(source, match.start()), declared, shown)
+ )
+ expected = at(declared)
+ if abs(x - expected) > TICK_TOLERANCE:
+ findings.append(
+ "%s:%d: a tick for %g is drawn at x=%g, but the boxes' scale "
+ "puts that value at x=%g"
+ % (name, line_of(source, match.start()), declared, x, expected)
+ )
+ ticks.append(declared)
+ if len(set(ticks)) < 2:
+ findings.append(
+ "%s: the value axis needs at least two bound ticks so the printed "
+ "scale and the drawn boxes cannot drift apart" % name
+ )
+
+
+def inside_span(offset: int, spans: list) -> bool:
+ return any(start <= offset < end for start, end in spans)
+
+
+def check_structure(source: str, items: list, findings: list, name: str) -> None:
+ """Carriers that move or hide a series without touching a checked attribute."""
+ for match in FORBIDDEN_RE.finditer(source):
+ tag = match.group("tag").lower()
+ findings.append(
+ "%s:%d: <%s> is unsupported — it can move a series after the "
+ "checker has read its raw coordinates"
+ % (name, line_of(source, match.start()), tag)
+ )
+ opens = [match.start() for match in re.finditer(r"<svg\b", source, re.IGNORECASE)]
+ if len(opens) > 1:
+ findings.append(
+ "%s:%d: a nested <svg> viewport shifts the series it wraps "
+ "without a transform on the marks"
+ % (name, line_of(source, opens[1]))
+ )
+ for match in LINK_RE.finditer(source):
+ attrs = attrs_of(match.group("attrs"))
+ rel = attrs.get("rel", "").casefold().split()
+ if "stylesheet" not in rel:
+ continue
+ if font_stylesheet(attrs.get("href", "").strip()):
+ continue
+ findings.append(
+ "%s:%d: a stylesheet link other than the font link can restyle "
+ "a box the attributes never state"
+ % (name, line_of(source, match.start()))
+ )
+ hidden = nonrendering_spans(source)
+ for item in items:
+ if inside_span(item.offset, hidden):
+ findings.append(
+ "%s:%d: series %r is inside a non-rendering container — a "
+ "copy in <defs> is not the series that gets drawn"
+ % (name, line_of(source, item.offset), item.name)
+ )
+ spans = [(item.body_at, item.body_end) for item in items]
+ for circle in CIRCLE_RE.finditer(source):
+ cattrs = attrs_of(circle.group("attrs"))
+ if "data-outlier" not in cattrs:
+ continue
+ owner = cattrs["data-outlier"].strip()
+ home = any(
+ item.name.strip() == owner
+ and item.body_at <= circle.start() < item.body_end
+ for item in items
+ )
+ if not home:
+ findings.append(
+ "%s:%d: a data-outlier circle for %r is not inside that "
+ "series group — a mark read outside the group it names is "
+ "never checked against the fence"
+ % (name, line_of(source, circle.start()), owner)
+ )
+ for regex in (RECT_RE, LINE_RE):
+ for match in regex.finditer(source):
+ role = attrs_of(match.group("attrs")).get("data-role")
+ if role not in MARK_ROLES or inside_span(match.start(), spans):
+ continue
+ findings.append(
+ "%s:%d: a data-role=%r mark sits outside every series group "
+ "— geometry the checker does not bind to a five-number summary"
+ % (name, line_of(source, match.start()), role)
+ )
+
+
+def check_source(path: Path, raw: str) -> list:
+ source = blank_comments(raw)
+ findings: list = []
+ name = path.name
+ items = parse_series(source, findings, name)
+ names_ok = True
+ check_names(items, findings, name)
+ check_structure(source, items, findings, name)
+ if len(items) > MAX_SERIES:
+ findings.append(
+ "%s: %d series against a budget of %d-%d — split an overview "
+ "from per-series detail"
+ % (name, len(items), MIN_SERIES, MAX_SERIES)
+ )
+ elif len(items) < MIN_SERIES:
+ findings.append(
+ "%s: presents as a box plot but declares %d verifiable "
+ "series — below %d there is no distribution to summarise, and a "
+ "table says it shorter" % (name, len(items), MIN_SERIES)
+ )
+ names_ok = False
+ if names_ok and items:
+ for item in items:
+ if not (item.wlo <= item.q1 <= item.q2 <= item.q3 <= item.whi):
+ findings.append(
+ "%s:%d: series %r declares wlo=%g, q1=%g, q2=%g, q3=%g, "
+ "whi=%g — a five-number summary is ordered "
+ "wlo ≤ q1 ≤ q2 ≤ q3 ≤ whi"
+ % (name, source.count("\n", 0, item.offset) + 1, item.name,
+ item.wlo, item.q1, item.q2, item.q3, item.whi)
+ )
+ check_transforms(source, findings, name)
+ scale = check_scale(items, findings, source, name)
+ check_shapes(items, findings, source, name)
+ check_labels(items, findings, source, name)
+ check_focal(items, findings, name)
+ check_ticks(scale, source, findings, name)
+ elif items:
+ check_transforms(source, findings, name)
+ return findings
+
+
+def check(path: Path) -> list:
+ raw = path.read_text(encoding="utf-8")
+ if not looks_like_box_plot(path, raw):
+ return []
+ return check_source(path, raw)
+
+
+def main() -> int:
+ parser = argparse.ArgumentParser(
+ description="Verify box-plot geometry against the five-number values "
+ "they declare."
+ )
+ parser.add_argument("paths", nargs="*", help="HTML files to check")
+ parser.add_argument(
+ "--all", action="store_true",
+ help="check every shipped example that presents as a box plot",
+ )
+ args = parser.parse_args()
+ if not args.all and not args.paths:
+ parser.print_help()
+ return 2
+
+ if args.all:
+ targets = sorted(ASSET_DIR.glob("example-*.html"))
+ else:
+ targets = [Path(p) for p in args.paths]
+
+ findings: list = []
+ checked = 0
+ skipped = 0
+ for path in targets:
+ if not path.is_file():
+ print("error: %s is not a readable file" % path, file=sys.stderr)
+ return 2
+ try:
+ raw = path.read_text(encoding="utf-8")
+ except (OSError, UnicodeDecodeError) as error:
+ print("error: cannot read %s: %s" % (path, error), file=sys.stderr)
+ return 2
+ if not looks_like_box_plot(path, raw):
+ skipped += 1
+ continue
+ findings.extend(check_source(path, raw))
+ checked += 1
+
+ for finding in findings:
+ print(finding)
+ tail = " (%d file(s) skipped as out of scope)" % skipped if skipped else ""
+ if findings:
+ print("\n%d box-plot finding(s) across %d file(s).%s"
+ % (len(findings), checked, tail))
+ return 1
+ if not checked:
+ print("OK box plot: no box plot found to check%s" % tail)
+ return 0
+ print("OK box plot: %d file(s), every box, median, whisker and outlier "
+ "exactly at its value on one shared scale, ordered five-number "
+ "summaries, at most one accent series, and every bound tick agreeing "
+ "with the mark it names%s" % (checked, tail))
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/skills/diagram-design/SKILL.md b/skills/diagram-design/SKILL.md
index a78a294..6eb0301 100644
--- a/skills/diagram-design/SKILL.md
+++ b/skills/diagram-design/SKILL.md
@@ -1,6 +1,6 @@
---
name: diagram-design
-description: Create branded architecture, architecture delta, IT current-state, flowchart, sequence, state machine, ER/data model, timeline, swimlane, quadrant, radar/spider, polar chart (polar/radial lollipop), loop/flywheel, nested, tree, org chart, layer stack, exploded axonometric, axonometric plan, Venn, pyramid/funnel, treemap and marimekko, heatmap, bar and dumbbell, waterfall, line (slopegraph, ridgeline, streamgraph, bump), Gantt and scatter charts (bubble, beeswarm), high-level, process, medallion, data flow, DP integration, DP security matrix, Sankey, fishbone, Wardley map, kanban, user journey, service blueprint, deployment, dependency graph, UML class, story map, or database schema diagrams as HTML/SVG/PNG, with .drawio, Mermaid, and .excalidraw import, plus lifecycle phase maps, block decomposition trees, and onboarding guidance.
+description: Create branded architecture, architecture delta, IT current-state, flowchart, sequence, state machine, ER/data model, timeline, swimlane, quadrant, radar/spider, polar chart (polar/radial lollipop), loop/flywheel, nested, tree, org chart, layer stack, exploded axonometric, axonometric plan, Venn, pyramid/funnel, treemap and marimekko, heatmap, bar and dumbbell, waterfall, line (slopegraph, ridgeline, streamgraph, bump), Gantt and scatter charts (bubble, beeswarm, box plot), high-level, process, medallion, data flow, DP integration, DP security matrix, Sankey, fishbone, Wardley map, kanban, user journey, service blueprint, deployment, dependency graph, UML class, story map, or database schema diagrams as HTML/SVG/PNG, with .drawio, Mermaid, and .excalidraw import, plus lifecycle phase maps, block decomposition trees, and onboarding guidance.
license: MIT
metadata:
version: "2.6"
@@ -111,7 +111,7 @@ The pattern owns semantic primitives and its tighter budget; the type owns layou
| Cross-tabulated data; fill encodes value per cell | **Heatmap** | [type-heatmap.md](references/type-heatmap.md) |
| Continuous trends over time, change between exactly two states (slopegraph), one distribution per series (ridgeline), or rank movement across several snapshots (bump) | **Line chart** | [type-line.md](references/type-line.md) |
| Tasks and phases on a timeline | **Gantt** | [type-gantt.md](references/type-gantt.md) |
-| Correlation or distribution of two variables; bubble (three variables) and beeswarm (one variable, dot per item) variants | **Scatter plot** | [type-scatter.md](references/type-scatter.md) |
+| Correlation or distribution of two variables; bubble (three variables), beeswarm (one variable, dot per item), and box plot (five-number summary per group) variants | **Scatter plot** | [type-scatter.md](references/type-scatter.md) |
| End-to-end data stack on a container cluster | **High-Level** | [type-high-level.md](references/type-high-level.md) |
| Multi-actor sequential process with data handoffs | **Process** | [type-process.md](references/type-process.md) |
| Multi-tier data storage with quality levels and access policies | **Medallion** | [type-medallion.md](references/type-medallion.md) |
diff --git a/skills/diagram-design/assets/example-box-plot-dark.html b/skills/diagram-design/assets/example-box-plot-dark.html
new file mode 100644
index 0000000..e052dc5
--- /dev/null
+++ b/skills/diagram-design/assets/example-box-plot-dark.html
@@ -0,0 +1,127 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Checkout's box is the incident · Box plot · dark</title>
+ <link href="https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Geist:wght@400;500;600&family=Geist+Mono:wght@400;500;600&display=swap" rel="stylesheet">
+ <style>
+ *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
+ :root {
+ --color-paper: #2d3142;
+ --color-ink: #f5f5f5;
+ --color-muted: #bfc0c0;
+ --color-accent: #f08a59;
+ --font-sans: 'Geist', system-ui, sans-serif;
+ --font-serif: 'Instrument Serif', serif;
+ --font-mono: 'Geist Mono', ui-monospace, monospace;
+ }
+ body { font-family: var(--font-sans); background: var(--color-paper); color: var(--color-ink); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 3rem 2rem; }
+ .frame { max-width: 1200px; width: 100%; }
+ .eyebrow { font-family: var(--font-mono); font-size: 0.66rem; font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase; color: var(--color-muted); margin-bottom: 0.5rem; }
+ h1 { font-family: var(--font-serif); font-size: clamp(1.5rem, 2.4vw + 0.75rem, 2rem); font-weight: 400; letter-spacing: -0.02em; line-height: 1.15; margin-bottom: 1.5rem; }
+ svg { width: 100%; min-width: 760px; display: block; }
+ </style>
+</head>
+<body>
+ <div class="frame">
+ <p class="eyebrow">Box plot · Diagram Design</p>
+ <h1>Checkout's box is the incident</h1>
+
+ <!-- Value axis: 0–400 ms over 800px, x = 160 + 2·ms, linear from zero.
+ Each series is a five-number summary on that shared scale; category y
+ is a label rail and carries no value. scripts/verify-box-plot.py
+ derives the scale from the declared quartiles and flags any mark
+ that disagrees with its peers. -->
+ <svg viewBox="0 0 1000 500" xmlns="http://www.w3.org/2000/svg" role="img" aria-labelledby="box-plot-dark-title box-plot-dark-desc">
+ <title id="box-plot-dark-title">Checkout's box is the incident</title>
+ <desc id="box-plot-dark-desc">Horizontal box plots of per-request latency for five services on a shared linear axis from zero; Checkout's interquartile range runs from 80 to 200 ms with outliers at 388 and 396 ms.</desc>
+ <defs>
+ <pattern id="dots" width="22" height="22" patternUnits="userSpaceOnUse">
+ <circle cx="1" cy="1" r="0.9" fill="rgba(245,245,245,0.10)"/>
+ </pattern>
+ </defs>
+ <rect width="100%" height="100%" fill="#2d3142"/>
+ <rect width="100%" height="100%" fill="url(#dots)" opacity="0.55"/>
+ <text x="560" y="456" fill="#bfc0c0" font-size="7" font-family="'Geist Mono', monospace" letter-spacing="0.14em" text-anchor="middle">PER-REQUEST LATENCY, MS</text>
+ <line x1="160" y1="56" x2="160" y2="400" stroke="rgba(245,245,245,0.06)" stroke-width="0.8"/>
+ <line x1="360" y1="56" x2="360" y2="400" stroke="rgba(245,245,245,0.08)" stroke-width="0.8"/>
+ <line x1="560" y1="56" x2="560" y2="400" stroke="rgba(245,245,245,0.08)" stroke-width="0.8"/>
+ <line x1="760" y1="56" x2="760" y2="400" stroke="rgba(245,245,245,0.08)" stroke-width="0.8"/>
+ <line x1="960" y1="56" x2="960" y2="400" stroke="rgba(245,245,245,0.06)" stroke-width="0.8"/>
+ <line x1="160" y1="420" x2="960" y2="420" stroke="rgba(245,245,245,0.25)" stroke-width="1"/>
+ <text data-tick="x" data-value="0" x="160" y="440" fill="#bfc0c0" font-size="8" font-family="'Geist Mono', monospace" text-anchor="middle">0</text>
+ <text data-tick="x" data-value="100" x="360" y="440" fill="#bfc0c0" font-size="8" font-family="'Geist Mono', monospace" text-anchor="middle">100</text>
+ <text data-tick="x" data-value="200" x="560" y="440" fill="#bfc0c0" font-size="8" font-family="'Geist Mono', monospace" text-anchor="middle">200</text>
+ <text data-tick="x" data-value="300" x="760" y="440" fill="#bfc0c0" font-size="8" font-family="'Geist Mono', monospace" text-anchor="middle">300</text>
+ <text data-tick="x" data-value="400" x="960" y="440" fill="#bfc0c0" font-size="8" font-family="'Geist Mono', monospace" text-anchor="middle">400</text>
+ <!-- x = 160 + 2·ms over a 0–400 domain. Category y is a label rail.
+ scripts/verify-box-plot.py derives the value scale from the
+ declared five-number summaries and flags any mark that disagrees. -->
+ <g data-name="Auth" data-q1="18" data-q2="22" data-q3="28" data-wlo="12" data-whi="40">
+ <line data-role="whisker-lo" x1="184" y1="80" x2="196" y2="80" stroke="rgba(245,245,245,0.40)" stroke-width="1"/>
+ <line data-role="whisker-hi" x1="216" y1="80" x2="240" y2="80" stroke="rgba(245,245,245,0.40)" stroke-width="1"/>
+ <line data-role="cap" x1="184" y1="72" x2="184" y2="88" stroke="rgba(245,245,245,0.40)" stroke-width="1"/>
+ <line data-role="cap" x1="240" y1="72" x2="240" y2="88" stroke="rgba(245,245,245,0.40)" stroke-width="1"/>
+ <rect x="196" y="64.0" width="20" height="32" rx="2" fill="#2d3142"/>
+ <rect data-role="box" x="196" y="64.0" width="20" height="32" rx="2" fill="rgba(245,245,245,0.14)" stroke="#bfc0c0" stroke-width="1"/>
+ <line data-role="median" x1="204" y1="64.0" x2="204" y2="96.0" stroke="#f5f5f5" stroke-width="1.5"/>
+ <text data-name="Auth" x="148" y="84" fill="#f5f5f5" font-size="11" font-weight="600" font-family="'Geist', sans-serif" text-anchor="end">Auth</text>
+ </g>
+ <g data-name="Catalog" data-q1="30" data-q2="46" data-q3="70" data-wlo="16" data-whi="90">
+ <line data-role="whisker-lo" x1="192" y1="148" x2="220" y2="148" stroke="rgba(245,245,245,0.40)" stroke-width="1"/>
+ <line data-role="whisker-hi" x1="300" y1="148" x2="340" y2="148" stroke="rgba(245,245,245,0.40)" stroke-width="1"/>
+ <line data-role="cap" x1="192" y1="140" x2="192" y2="156" stroke="rgba(245,245,245,0.40)" stroke-width="1"/>
+ <line data-role="cap" x1="340" y1="140" x2="340" y2="156" stroke="rgba(245,245,245,0.40)" stroke-width="1"/>
+ <rect x="220" y="132.0" width="80" height="32" rx="2" fill="#2d3142"/>
+ <rect data-role="box" x="220" y="132.0" width="80" height="32" rx="2" fill="rgba(245,245,245,0.14)" stroke="#bfc0c0" stroke-width="1"/>
+ <line data-role="median" x1="252" y1="132.0" x2="252" y2="164.0" stroke="#f5f5f5" stroke-width="1.5"/>
+ <text data-name="Catalog" x="148" y="152" fill="#f5f5f5" font-size="11" font-weight="600" font-family="'Geist', sans-serif" text-anchor="end">Catalog</text>
+ </g>
+ <g data-name="Checkout" data-q1="80" data-q2="120" data-q3="200" data-wlo="40" data-whi="280">
+ <line data-role="whisker-lo" x1="240" y1="216" x2="320" y2="216" stroke="rgba(245,245,245,0.40)" stroke-width="1"/>
+ <line data-role="whisker-hi" x1="560" y1="216" x2="720" y2="216" stroke="rgba(245,245,245,0.40)" stroke-width="1"/>
+ <line data-role="cap" x1="240" y1="208" x2="240" y2="224" stroke="rgba(245,245,245,0.40)" stroke-width="1"/>
+ <line data-role="cap" x1="720" y1="208" x2="720" y2="224" stroke="rgba(245,245,245,0.40)" stroke-width="1"/>
+ <rect x="320" y="200.0" width="240" height="32" rx="2" fill="#2d3142"/>
+ <rect data-role="box" x="320" y="200.0" width="240" height="32" rx="2" fill="rgba(240,138,89,0.18)" stroke="#f08a59" stroke-width="1.2"/>
+ <line data-role="median" x1="400" y1="200.0" x2="400" y2="232.0" stroke="#f5f5f5" stroke-width="1.5"/>
+ <circle cx="936" cy="216" r="4" fill="#2d3142"/>
+ <circle data-outlier="Checkout" data-x="388" cx="936" cy="216" r="4" fill="rgba(240,138,89,0.55)" stroke="#f08a59" stroke-width="0.75"/>
+ <circle cx="952" cy="216" r="4" fill="#2d3142"/>
+ <circle data-outlier="Checkout" data-x="396" cx="952" cy="216" r="4" fill="rgba(240,138,89,0.55)" stroke="#f08a59" stroke-width="0.75"/>
+ <text data-name="Checkout" x="148" y="220" fill="#f5f5f5" font-size="11" font-weight="600" font-family="'Geist', sans-serif" text-anchor="end">Checkout</text>
+ </g>
+ <g data-name="Search" data-q1="22" data-q2="28" data-q3="40" data-wlo="8" data-whi="64">
+ <line data-role="whisker-lo" x1="176" y1="284" x2="204" y2="284" stroke="rgba(245,245,245,0.40)" stroke-width="1"/>
+ <line data-role="whisker-hi" x1="240" y1="284" x2="288" y2="284" stroke="rgba(245,245,245,0.40)" stroke-width="1"/>
+ <line data-role="cap" x1="176" y1="276" x2="176" y2="292" stroke="rgba(245,245,245,0.40)" stroke-width="1"/>
+ <line data-role="cap" x1="288" y1="276" x2="288" y2="292" stroke="rgba(245,245,245,0.40)" stroke-width="1"/>
+ <rect x="204" y="268.0" width="36" height="32" rx="2" fill="#2d3142"/>
+ <rect data-role="box" x="204" y="268.0" width="36" height="32" rx="2" fill="rgba(245,245,245,0.14)" stroke="#bfc0c0" stroke-width="1"/>
+ <line data-role="median" x1="216" y1="268.0" x2="216" y2="300.0" stroke="#f5f5f5" stroke-width="1.5"/>
+ <text data-name="Search" x="148" y="288" fill="#f5f5f5" font-size="11" font-weight="600" font-family="'Geist', sans-serif" text-anchor="end">Search</text>
+ </g>
+ <g data-name="Billing" data-q1="36" data-q2="42" data-q3="50" data-wlo="20" data-whi="70">
+ <line data-role="whisker-lo" x1="200" y1="352" x2="232" y2="352" stroke="rgba(245,245,245,0.40)" stroke-width="1"/>
+ <line data-role="whisker-hi" x1="260" y1="352" x2="300" y2="352" stroke="rgba(245,245,245,0.40)" stroke-width="1"/>
+ <line data-role="cap" x1="200" y1="344" x2="200" y2="360" stroke="rgba(245,245,245,0.40)" stroke-width="1"/>
+ <line data-role="cap" x1="300" y1="344" x2="300" y2="360" stroke="rgba(245,245,245,0.40)" stroke-width="1"/>
+ <rect x="232" y="336.0" width="28" height="32" rx="2" fill="#2d3142"/>
+ <rect data-role="box" x="232" y="336.0" width="28" height="32" rx="2" fill="rgba(245,245,245,0.14)" stroke="#bfc0c0" stroke-width="1"/>
+ <line data-role="median" x1="244" y1="336.0" x2="244" y2="368.0" stroke="#f5f5f5" stroke-width="1.5"/>
+ <circle cx="352" cy="352" r="4" fill="#2d3142"/>
+ <circle data-outlier="Billing" data-x="96" cx="352" cy="352" r="4" fill="rgba(245,245,245,0.55)" stroke="#bfc0c0" stroke-width="0.75"/>
+ <text data-name="Billing" x="148" y="356" fill="#f5f5f5" font-size="11" font-weight="600" font-family="'Geist', sans-serif" text-anchor="end">Billing</text>
+ </g>
+ <line x1="40" y1="462" x2="960" y2="462" stroke="rgba(245,245,245,0.10)" stroke-width="0.8"/>
+ <text x="40" y="478" fill="#bfc0c0" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.18em">LEGEND</text>
+ <text x="960" y="478" fill="#bfc0c0" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.06em" text-anchor="end">BOX = IQR · LINE = MEDIAN · DOT = OUTLIER</text>
+ <rect x="44" y="484" width="16" height="10" rx="2" fill="rgba(240,138,89,0.18)" stroke="#f08a59" stroke-width="1.2"/>
+ <text x="68" y="494" fill="#bfc0c0" font-size="8.5" font-family="'Geist', sans-serif">Checkout · focal, the IQR that will page</text>
+ <rect x="360" y="484" width="16" height="10" rx="2" fill="rgba(245,245,245,0.14)" stroke="#bfc0c0" stroke-width="1"/>
+ <text x="384" y="494" fill="#bfc0c0" font-size="8.5" font-family="'Geist', sans-serif">service · box is q1–q3, whisker to the last inlier</text>
+ </svg>
+ </div>
+</body>
+</html>
diff --git a/skills/diagram-design/assets/example-box-plot-full.html b/skills/diagram-design/assets/example-box-plot-full.html
new file mode 100644
index 0000000..3ebd0a8
--- /dev/null
+++ b/skills/diagram-design/assets/example-box-plot-full.html
@@ -0,0 +1,159 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Checkout's box is the incident · Box plot</title>
+ <link href="https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Geist:wght@400;500;600&family=Geist+Mono:wght@400;500;600&display=swap" rel="stylesheet">
+ <style>
+ *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
+ :root { --color-paper:#f5f5f5; --color-paper-2:#ececec; --color-ink:#2d3142; --color-muted:#4f5d75; --color-soft:#5a6580; --color-rule:rgba(45,49,66,0.12); --color-accent:#bf4520; --font-sans:'Geist',system-ui,sans-serif; --font-serif:'Instrument Serif',serif; --font-mono:'Geist Mono',ui-monospace,monospace; }
+ body { font-family: var(--font-sans); background: var(--color-paper); min-height: 100vh; padding: 3rem 2rem; color: var(--color-ink); }
+ .container { max-width: 1200px; margin: 0 auto; }
+ .header { margin-bottom: 2.5rem; }
+ .header-eyebrow { font-family: var(--font-mono); font-size: 0.66rem; font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase; color: var(--color-muted); margin-bottom: 0.75rem; }
+ h1 { font-family: var(--font-serif); font-size: clamp(1.75rem, 3vw + 1rem, 2.5rem); font-weight: 400; letter-spacing: -0.02em; line-height: 1.1; margin-bottom: 0.5rem; }
+ .subtitle { font-size: 1rem; line-height: 1.55; color: var(--color-muted); max-width: 58ch; }
+ .diagram-container { background: var(--color-paper-2); border-radius: 8px; border: 1px solid var(--color-rule); padding: 1.5rem; overflow-x: auto; }
+ svg { width: 100%; min-width: 760px; display: block; }
+ .cards { display: grid; grid-template-columns: 1.1fr 1fr 0.9fr; gap: 1rem; margin-top: 1.5rem; }
+ @media (max-width: 720px) { .cards { grid-template-columns: 1fr; } }
+ .card { background: #fff; border-radius: 6px; border: 1px solid var(--color-rule); padding: 1.25rem; }
+ .card .eyebrow { font-family: var(--font-mono); font-size: 0.5rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--color-muted); margin-bottom: 0.5rem; }
+ .card-header { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.875rem; padding-bottom: 0.875rem; border-bottom: 1px solid rgba(45,49,66,0.08); }
+ .card-dot { width: 7px; height: 7px; border-radius: 50%; }
+ .card-dot.coral { background: var(--color-accent); }
+ .card-dot.ink-strong { background: rgba(45,49,66,0.80); }
+ .card-dot.ink-light { background: rgba(45,49,66,0.62); }
+ .card h3 { font-size: 0.875rem; font-weight: 600; }
+ .card p { color: var(--color-muted); font-size: 0.8125rem; line-height: 1.55; }
+ .footer { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid rgba(45,49,66,0.10); font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.06em; color: var(--color-muted); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; }
+ </style>
+</head>
+<body>
+ <div class="container">
+ <div class="header">
+ <p class="header-eyebrow">Box plot · Diagram Design</p>
+ <h1>Checkout's box is the incident</h1>
+ <p class="subtitle">Five services, one shared latency axis from zero. Auth and Search keep a tight box under 40&nbsp;ms. Checkout's box already runs 80–200&nbsp;ms, and two requests sit past 380&nbsp;ms — the median still looks survivable, which is exactly why the box is the reading that matters.</p>
+ </div>
+ <div class="diagram-container">
+ <!-- Value axis: 0–400 ms over 800px, x = 160 + 2·ms, linear from zero.
+ Each series is a five-number summary on that shared scale; category y
+ is a label rail and carries no value. scripts/verify-box-plot.py
+ derives the scale from the declared quartiles and flags any mark
+ that disagrees with its peers. -->
+ <svg viewBox="0 0 1000 500" xmlns="http://www.w3.org/2000/svg" role="img" aria-labelledby="box-plot-full-title box-plot-full-desc">
+ <title id="box-plot-full-title">Checkout's box is the incident</title>
+ <desc id="box-plot-full-desc">Horizontal box plots of per-request latency for five services on a shared linear axis from zero; Checkout's interquartile range runs from 80 to 200 ms with outliers at 388 and 396 ms.</desc>
+ <defs>
+ <pattern id="dots" width="22" height="22" patternUnits="userSpaceOnUse">
+ <circle cx="1" cy="1" r="0.9" fill="rgba(45,49,66,0.10)"/>
+ </pattern>
+ </defs>
+ <rect width="100%" height="100%" fill="#f5f5f5"/>
+ <rect width="100%" height="100%" fill="url(#dots)" opacity="0.55"/>
+ <text x="560" y="456" fill="#4f5d75" font-size="7" font-family="'Geist Mono', monospace" letter-spacing="0.14em" text-anchor="middle">PER-REQUEST LATENCY, MS</text>
+ <line x1="160" y1="56" x2="160" y2="400" stroke="rgba(45,49,66,0.06)" stroke-width="0.8"/>
+ <line x1="360" y1="56" x2="360" y2="400" stroke="rgba(45,49,66,0.08)" stroke-width="0.8"/>
+ <line x1="560" y1="56" x2="560" y2="400" stroke="rgba(45,49,66,0.08)" stroke-width="0.8"/>
+ <line x1="760" y1="56" x2="760" y2="400" stroke="rgba(45,49,66,0.08)" stroke-width="0.8"/>
+ <line x1="960" y1="56" x2="960" y2="400" stroke="rgba(45,49,66,0.06)" stroke-width="0.8"/>
+ <line x1="160" y1="420" x2="960" y2="420" stroke="rgba(45,49,66,0.25)" stroke-width="1"/>
+ <text data-tick="x" data-value="0" x="160" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" text-anchor="middle">0</text>
+ <text data-tick="x" data-value="100" x="360" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" text-anchor="middle">100</text>
+ <text data-tick="x" data-value="200" x="560" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" text-anchor="middle">200</text>
+ <text data-tick="x" data-value="300" x="760" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" text-anchor="middle">300</text>
+ <text data-tick="x" data-value="400" x="960" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" text-anchor="middle">400</text>
+ <!-- x = 160 + 2·ms over a 0–400 domain. Category y is a label rail.
+ scripts/verify-box-plot.py derives the value scale from the
+ declared five-number summaries and flags any mark that disagrees. -->
+ <g data-name="Auth" data-q1="18" data-q2="22" data-q3="28" data-wlo="12" data-whi="40">
+ <line data-role="whisker-lo" x1="184" y1="80" x2="196" y2="80" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="whisker-hi" x1="216" y1="80" x2="240" y2="80" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="cap" x1="184" y1="72" x2="184" y2="88" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="cap" x1="240" y1="72" x2="240" y2="88" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <rect x="196" y="64.0" width="20" height="32" rx="2" fill="#f5f5f5"/>
+ <rect data-role="box" x="196" y="64.0" width="20" height="32" rx="2" fill="rgba(45,49,66,0.15)" stroke="#4f5d75" stroke-width="1"/>
+ <line data-role="median" x1="204" y1="64.0" x2="204" y2="96.0" stroke="#2d3142" stroke-width="1.5"/>
+ <text data-name="Auth" x="148" y="84" fill="#2d3142" font-size="11" font-weight="600" font-family="'Geist', sans-serif" text-anchor="end">Auth</text>
+ </g>
+ <g data-name="Catalog" data-q1="30" data-q2="46" data-q3="70" data-wlo="16" data-whi="90">
+ <line data-role="whisker-lo" x1="192" y1="148" x2="220" y2="148" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="whisker-hi" x1="300" y1="148" x2="340" y2="148" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="cap" x1="192" y1="140" x2="192" y2="156" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="cap" x1="340" y1="140" x2="340" y2="156" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <rect x="220" y="132.0" width="80" height="32" rx="2" fill="#f5f5f5"/>
+ <rect data-role="box" x="220" y="132.0" width="80" height="32" rx="2" fill="rgba(45,49,66,0.15)" stroke="#4f5d75" stroke-width="1"/>
+ <line data-role="median" x1="252" y1="132.0" x2="252" y2="164.0" stroke="#2d3142" stroke-width="1.5"/>
+ <text data-name="Catalog" x="148" y="152" fill="#2d3142" font-size="11" font-weight="600" font-family="'Geist', sans-serif" text-anchor="end">Catalog</text>
+ </g>
+ <g data-name="Checkout" data-q1="80" data-q2="120" data-q3="200" data-wlo="40" data-whi="280">
+ <line data-role="whisker-lo" x1="240" y1="216" x2="320" y2="216" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="whisker-hi" x1="560" y1="216" x2="720" y2="216" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="cap" x1="240" y1="208" x2="240" y2="224" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="cap" x1="720" y1="208" x2="720" y2="224" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <rect x="320" y="200.0" width="240" height="32" rx="2" fill="#f5f5f5"/>
+ <rect data-role="box" x="320" y="200.0" width="240" height="32" rx="2" fill="rgba(191,69,32,0.12)" stroke="#bf4520" stroke-width="1.2"/>
+ <line data-role="median" x1="400" y1="200.0" x2="400" y2="232.0" stroke="#2d3142" stroke-width="1.5"/>
+ <circle cx="936" cy="216" r="4" fill="#f5f5f5"/>
+ <circle data-outlier="Checkout" data-x="388" cx="936" cy="216" r="4" fill="rgba(191,69,32,0.55)" stroke="#bf4520" stroke-width="0.75"/>
+ <circle cx="952" cy="216" r="4" fill="#f5f5f5"/>
+ <circle data-outlier="Checkout" data-x="396" cx="952" cy="216" r="4" fill="rgba(191,69,32,0.55)" stroke="#bf4520" stroke-width="0.75"/>
+ <text data-name="Checkout" x="148" y="220" fill="#2d3142" font-size="11" font-weight="600" font-family="'Geist', sans-serif" text-anchor="end">Checkout</text>
+ </g>
+ <g data-name="Search" data-q1="22" data-q2="28" data-q3="40" data-wlo="8" data-whi="64">
+ <line data-role="whisker-lo" x1="176" y1="284" x2="204" y2="284" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="whisker-hi" x1="240" y1="284" x2="288" y2="284" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="cap" x1="176" y1="276" x2="176" y2="292" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="cap" x1="288" y1="276" x2="288" y2="292" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <rect x="204" y="268.0" width="36" height="32" rx="2" fill="#f5f5f5"/>
+ <rect data-role="box" x="204" y="268.0" width="36" height="32" rx="2" fill="rgba(45,49,66,0.15)" stroke="#4f5d75" stroke-width="1"/>
+ <line data-role="median" x1="216" y1="268.0" x2="216" y2="300.0" stroke="#2d3142" stroke-width="1.5"/>
+ <text data-name="Search" x="148" y="288" fill="#2d3142" font-size="11" font-weight="600" font-family="'Geist', sans-serif" text-anchor="end">Search</text>
+ </g>
+ <g data-name="Billing" data-q1="36" data-q2="42" data-q3="50" data-wlo="20" data-whi="70">
+ <line data-role="whisker-lo" x1="200" y1="352" x2="232" y2="352" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="whisker-hi" x1="260" y1="352" x2="300" y2="352" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="cap" x1="200" y1="344" x2="200" y2="360" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="cap" x1="300" y1="344" x2="300" y2="360" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <rect x="232" y="336.0" width="28" height="32" rx="2" fill="#f5f5f5"/>
+ <rect data-role="box" x="232" y="336.0" width="28" height="32" rx="2" fill="rgba(45,49,66,0.15)" stroke="#4f5d75" stroke-width="1"/>
+ <line data-role="median" x1="244" y1="336.0" x2="244" y2="368.0" stroke="#2d3142" stroke-width="1.5"/>
+ <circle cx="352" cy="352" r="4" fill="#f5f5f5"/>
+ <circle data-outlier="Billing" data-x="96" cx="352" cy="352" r="4" fill="rgba(45,49,66,0.55)" stroke="#4f5d75" stroke-width="0.75"/>
+ <text data-name="Billing" x="148" y="356" fill="#2d3142" font-size="11" font-weight="600" font-family="'Geist', sans-serif" text-anchor="end">Billing</text>
+ </g>
+ <line x1="40" y1="462" x2="960" y2="462" stroke="rgba(45,49,66,0.10)" stroke-width="0.8"/>
+ <text x="40" y="478" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.18em">LEGEND</text>
+ <text x="960" y="478" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.06em" text-anchor="end">BOX = IQR · LINE = MEDIAN · DOT = OUTLIER</text>
+ <rect x="44" y="484" width="16" height="10" rx="2" fill="rgba(191,69,32,0.12)" stroke="#bf4520" stroke-width="1.2"/>
+ <text x="68" y="494" fill="#4f5d75" font-size="8.5" font-family="'Geist', sans-serif">Checkout · focal, the IQR that will page</text>
+ <rect x="360" y="484" width="16" height="10" rx="2" fill="rgba(45,49,66,0.15)" stroke="#4f5d75" stroke-width="1"/>
+ <text x="384" y="494" fill="#4f5d75" font-size="8.5" font-family="'Geist', sans-serif">service · box is q1–q3, whisker to the last inlier</text>
+ </svg>
+ </div>
+ <div class="cards">
+ <div class="card">
+ <div class="card-header"><span class="card-dot coral"></span><h3>The box, not the middle</h3></div>
+ <p class="eyebrow">Checkout pages on the IQR</p>
+ <p>Checkout's median is 120&nbsp;ms. Its box already spans 80–200&nbsp;ms, and two outliers sit at 388 and 396&nbsp;ms. A single average would have called this service healthy. The five-number summary is the incident.</p>
+ </div>
+ <div class="card">
+ <div class="card-header"><span class="card-dot ink-strong"></span><h3>One shared scale</h3></div>
+ <p class="eyebrow">Zero to 400 ms, linear</p>
+ <p>Every box, median, whisker and outlier sits on one linear axis from zero. Auth's entire box fits inside Checkout's lower whisker. That comparison is the point of putting five services on one figure.</p>
+ </div>
+ <div class="card">
+ <div class="card-header"><span class="card-dot ink-light"></span><h3>Outliers stay outside</h3></div>
+ <p class="eyebrow">Dots past the fence</p>
+ <p>Whiskers run to the last inlier, not to the theoretical fence, and the two Checkout requests past its 380&nbsp;ms fence keep their own marks. Drawing them on the whisker would have hidden the tail the title is about.</p>
+ </div>
+ </div>
+ <div class="footer">
+ <span>PER-REQUEST LATENCY · FIVE SERVICES · ILLUSTRATIVE FIGURES, NOT MEASURED TRAFFIC</span>
+ <span>DIAGRAM DESIGN · BOX PLOT</span>
+ </div>
+ </div>
+</body>
+</html>
diff --git a/skills/diagram-design/assets/example-box-plot.html b/skills/diagram-design/assets/example-box-plot.html
new file mode 100644
index 0000000..6d9f34e
--- /dev/null
+++ b/skills/diagram-design/assets/example-box-plot.html
@@ -0,0 +1,127 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Checkout's box is the incident · Box plot</title>
+ <link href="https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Geist:wght@400;500;600&family=Geist+Mono:wght@400;500;600&display=swap" rel="stylesheet">
+ <style>
+ *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
+ :root {
+ --color-paper: #f5f5f5;
+ --color-ink: #2d3142;
+ --color-muted: #4f5d75;
+ --color-accent: #bf4520;
+ --font-sans: 'Geist', system-ui, sans-serif;
+ --font-serif: 'Instrument Serif', serif;
+ --font-mono: 'Geist Mono', ui-monospace, monospace;
+ }
+ body { font-family: var(--font-sans); background: var(--color-paper); color: var(--color-ink); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 3rem 2rem; }
+ .frame { max-width: 1200px; width: 100%; }
+ .eyebrow { font-family: var(--font-mono); font-size: 0.66rem; font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase; color: var(--color-muted); margin-bottom: 0.5rem; }
+ h1 { font-family: var(--font-serif); font-size: clamp(1.5rem, 2.4vw + 0.75rem, 2rem); font-weight: 400; letter-spacing: -0.02em; line-height: 1.15; margin-bottom: 1.5rem; }
+ svg { width: 100%; min-width: 760px; display: block; }
+ </style>
+</head>
+<body>
+ <div class="frame">
+ <p class="eyebrow">Box plot · Diagram Design</p>
+ <h1>Checkout's box is the incident</h1>
+
+ <!-- Value axis: 0–400 ms over 800px, x = 160 + 2·ms, linear from zero.
+ Each series is a five-number summary on that shared scale; category y
+ is a label rail and carries no value. scripts/verify-box-plot.py
+ derives the scale from the declared quartiles and flags any mark
+ that disagrees with its peers. -->
+ <svg viewBox="0 0 1000 500" xmlns="http://www.w3.org/2000/svg" role="img" aria-labelledby="box-plot-title box-plot-desc">
+ <title id="box-plot-title">Checkout's box is the incident</title>
+ <desc id="box-plot-desc">Horizontal box plots of per-request latency for five services on a shared linear axis from zero; Checkout's interquartile range runs from 80 to 200 ms with outliers at 388 and 396 ms.</desc>
+ <defs>
+ <pattern id="dots" width="22" height="22" patternUnits="userSpaceOnUse">
+ <circle cx="1" cy="1" r="0.9" fill="rgba(45,49,66,0.10)"/>
+ </pattern>
+ </defs>
+ <rect width="100%" height="100%" fill="#f5f5f5"/>
+ <rect width="100%" height="100%" fill="url(#dots)" opacity="0.55"/>
+ <text x="560" y="456" fill="#4f5d75" font-size="7" font-family="'Geist Mono', monospace" letter-spacing="0.14em" text-anchor="middle">PER-REQUEST LATENCY, MS</text>
+ <line x1="160" y1="56" x2="160" y2="400" stroke="rgba(45,49,66,0.06)" stroke-width="0.8"/>
+ <line x1="360" y1="56" x2="360" y2="400" stroke="rgba(45,49,66,0.08)" stroke-width="0.8"/>
+ <line x1="560" y1="56" x2="560" y2="400" stroke="rgba(45,49,66,0.08)" stroke-width="0.8"/>
+ <line x1="760" y1="56" x2="760" y2="400" stroke="rgba(45,49,66,0.08)" stroke-width="0.8"/>
+ <line x1="960" y1="56" x2="960" y2="400" stroke="rgba(45,49,66,0.06)" stroke-width="0.8"/>
+ <line x1="160" y1="420" x2="960" y2="420" stroke="rgba(45,49,66,0.25)" stroke-width="1"/>
+ <text data-tick="x" data-value="0" x="160" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" text-anchor="middle">0</text>
+ <text data-tick="x" data-value="100" x="360" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" text-anchor="middle">100</text>
+ <text data-tick="x" data-value="200" x="560" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" text-anchor="middle">200</text>
+ <text data-tick="x" data-value="300" x="760" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" text-anchor="middle">300</text>
+ <text data-tick="x" data-value="400" x="960" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" text-anchor="middle">400</text>
+ <!-- x = 160 + 2·ms over a 0–400 domain. Category y is a label rail.
+ scripts/verify-box-plot.py derives the value scale from the
+ declared five-number summaries and flags any mark that disagrees. -->
+ <g data-name="Auth" data-q1="18" data-q2="22" data-q3="28" data-wlo="12" data-whi="40">
+ <line data-role="whisker-lo" x1="184" y1="80" x2="196" y2="80" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="whisker-hi" x1="216" y1="80" x2="240" y2="80" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="cap" x1="184" y1="72" x2="184" y2="88" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="cap" x1="240" y1="72" x2="240" y2="88" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <rect x="196" y="64.0" width="20" height="32" rx="2" fill="#f5f5f5"/>
+ <rect data-role="box" x="196" y="64.0" width="20" height="32" rx="2" fill="rgba(45,49,66,0.15)" stroke="#4f5d75" stroke-width="1"/>
+ <line data-role="median" x1="204" y1="64.0" x2="204" y2="96.0" stroke="#2d3142" stroke-width="1.5"/>
+ <text data-name="Auth" x="148" y="84" fill="#2d3142" font-size="11" font-weight="600" font-family="'Geist', sans-serif" text-anchor="end">Auth</text>
+ </g>
+ <g data-name="Catalog" data-q1="30" data-q2="46" data-q3="70" data-wlo="16" data-whi="90">
+ <line data-role="whisker-lo" x1="192" y1="148" x2="220" y2="148" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="whisker-hi" x1="300" y1="148" x2="340" y2="148" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="cap" x1="192" y1="140" x2="192" y2="156" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="cap" x1="340" y1="140" x2="340" y2="156" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <rect x="220" y="132.0" width="80" height="32" rx="2" fill="#f5f5f5"/>
+ <rect data-role="box" x="220" y="132.0" width="80" height="32" rx="2" fill="rgba(45,49,66,0.15)" stroke="#4f5d75" stroke-width="1"/>
+ <line data-role="median" x1="252" y1="132.0" x2="252" y2="164.0" stroke="#2d3142" stroke-width="1.5"/>
+ <text data-name="Catalog" x="148" y="152" fill="#2d3142" font-size="11" font-weight="600" font-family="'Geist', sans-serif" text-anchor="end">Catalog</text>
+ </g>
+ <g data-name="Checkout" data-q1="80" data-q2="120" data-q3="200" data-wlo="40" data-whi="280">
+ <line data-role="whisker-lo" x1="240" y1="216" x2="320" y2="216" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="whisker-hi" x1="560" y1="216" x2="720" y2="216" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="cap" x1="240" y1="208" x2="240" y2="224" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="cap" x1="720" y1="208" x2="720" y2="224" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <rect x="320" y="200.0" width="240" height="32" rx="2" fill="#f5f5f5"/>
+ <rect data-role="box" x="320" y="200.0" width="240" height="32" rx="2" fill="rgba(191,69,32,0.12)" stroke="#bf4520" stroke-width="1.2"/>
+ <line data-role="median" x1="400" y1="200.0" x2="400" y2="232.0" stroke="#2d3142" stroke-width="1.5"/>
+ <circle cx="936" cy="216" r="4" fill="#f5f5f5"/>
+ <circle data-outlier="Checkout" data-x="388" cx="936" cy="216" r="4" fill="rgba(191,69,32,0.55)" stroke="#bf4520" stroke-width="0.75"/>
+ <circle cx="952" cy="216" r="4" fill="#f5f5f5"/>
+ <circle data-outlier="Checkout" data-x="396" cx="952" cy="216" r="4" fill="rgba(191,69,32,0.55)" stroke="#bf4520" stroke-width="0.75"/>
+ <text data-name="Checkout" x="148" y="220" fill="#2d3142" font-size="11" font-weight="600" font-family="'Geist', sans-serif" text-anchor="end">Checkout</text>
+ </g>
+ <g data-name="Search" data-q1="22" data-q2="28" data-q3="40" data-wlo="8" data-whi="64">
+ <line data-role="whisker-lo" x1="176" y1="284" x2="204" y2="284" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="whisker-hi" x1="240" y1="284" x2="288" y2="284" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="cap" x1="176" y1="276" x2="176" y2="292" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="cap" x1="288" y1="276" x2="288" y2="292" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <rect x="204" y="268.0" width="36" height="32" rx="2" fill="#f5f5f5"/>
+ <rect data-role="box" x="204" y="268.0" width="36" height="32" rx="2" fill="rgba(45,49,66,0.15)" stroke="#4f5d75" stroke-width="1"/>
+ <line data-role="median" x1="216" y1="268.0" x2="216" y2="300.0" stroke="#2d3142" stroke-width="1.5"/>
+ <text data-name="Search" x="148" y="288" fill="#2d3142" font-size="11" font-weight="600" font-family="'Geist', sans-serif" text-anchor="end">Search</text>
+ </g>
+ <g data-name="Billing" data-q1="36" data-q2="42" data-q3="50" data-wlo="20" data-whi="70">
+ <line data-role="whisker-lo" x1="200" y1="352" x2="232" y2="352" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="whisker-hi" x1="260" y1="352" x2="300" y2="352" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="cap" x1="200" y1="344" x2="200" y2="360" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <line data-role="cap" x1="300" y1="344" x2="300" y2="360" stroke="rgba(45,49,66,0.55)" stroke-width="1"/>
+ <rect x="232" y="336.0" width="28" height="32" rx="2" fill="#f5f5f5"/>
+ <rect data-role="box" x="232" y="336.0" width="28" height="32" rx="2" fill="rgba(45,49,66,0.15)" stroke="#4f5d75" stroke-width="1"/>
+ <line data-role="median" x1="244" y1="336.0" x2="244" y2="368.0" stroke="#2d3142" stroke-width="1.5"/>
+ <circle cx="352" cy="352" r="4" fill="#f5f5f5"/>
+ <circle data-outlier="Billing" data-x="96" cx="352" cy="352" r="4" fill="rgba(45,49,66,0.55)" stroke="#4f5d75" stroke-width="0.75"/>
+ <text data-name="Billing" x="148" y="356" fill="#2d3142" font-size="11" font-weight="600" font-family="'Geist', sans-serif" text-anchor="end">Billing</text>
+ </g>
+ <line x1="40" y1="462" x2="960" y2="462" stroke="rgba(45,49,66,0.10)" stroke-width="0.8"/>
+ <text x="40" y="478" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.18em">LEGEND</text>
+ <text x="960" y="478" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.06em" text-anchor="end">BOX = IQR · LINE = MEDIAN · DOT = OUTLIER</text>
+ <rect x="44" y="484" width="16" height="10" rx="2" fill="rgba(191,69,32,0.12)" stroke="#bf4520" stroke-width="1.2"/>
+ <text x="68" y="494" fill="#4f5d75" font-size="8.5" font-family="'Geist', sans-serif">Checkout · focal, the IQR that will page</text>
+ <rect x="360" y="484" width="16" height="10" rx="2" fill="rgba(45,49,66,0.15)" stroke="#4f5d75" stroke-width="1"/>
+ <text x="384" y="494" fill="#4f5d75" font-size="8.5" font-family="'Geist', sans-serif">service · box is q1–q3, whisker to the last inlier</text>
+ </svg>
+ </div>
+</body>
+</html>
diff --git a/skills/diagram-design/assets/index.html b/skills/diagram-design/assets/index.html
index 205e637..1efc182 100644
--- a/skills/diagram-design/assets/index.html
+++ b/skills/diagram-design/assets/index.html
@@ -465,6 +465,9 @@
<button class="tab" data-type="beeswarm" data-parent-type="scatter">
<span class="eyebrow">28b</span>Scatter · beeswarm
</button>
+ <button class="tab" data-type="box-plot" data-parent-type="scatter">
+ <span class="eyebrow">28c</span>Scatter · box plot
+ </button>
<button class="tab" data-type="high-level">
<span class="eyebrow">29</span>High-Level
</button>
diff --git a/skills/diagram-design/references/layout-budget.md b/skills/diagram-design/references/layout-budget.md
index 3f3239e..8f44b43 100644
--- a/skills/diagram-design/references/layout-budget.md
+++ b/skills/diagram-design/references/layout-budget.md
@@ -51,6 +51,7 @@ These are the per-type limits. The universal rows in SKILL.md §7 (9 nodes, 12 a
| Max series (line chart) | 5 |
| Max tasks (Gantt) | 12 |
| Max points (scatter plot) | 30 |
+| Max series / outliers (box plot) | 8 / 8, 1 focal series |
| Max stages / nodes / flows (sankey) | 3 / 8 / 12 |
| Max categories (fishbone) | 6 bones, 3 sub-causes each |
| Max components / links (wardley) | 9 / 12, 2 movement arrows |
diff --git a/skills/diagram-design/references/type-line.md b/skills/diagram-design/references/type-line.md
index 6781c24..053089f 100644
--- a/skills/diagram-design/references/type-line.md
+++ b/skills/diagram-design/references/type-line.md
@@ -143,7 +143,7 @@ What each binding buys, and what it costs to omit:
### Ridgeline
-**Best for:** one **distribution** per series, stacked at a fixed pitch with deliberate overlap, when the shape of each distribution is the story and the series are directly comparable — request latency per service, build duration per pipeline, session length per cohort. The line chart above plots one value per x; a ridgeline plots a whole distribution per row, and the reading is the silhouette: where the mass sits, how tight it is, whether there is a second peak. A p50/p99 pair cannot show a bimodal service, and a box plot flattens it to a rectangle.
+**Best for:** one **distribution** per series, stacked at a fixed pitch with deliberate overlap, when the shape of each distribution is the story and the series are directly comparable — request latency per service, build duration per pipeline, session length per cohort. The line chart above plots one value per x; a ridgeline plots a whole distribution per row, and the reading is the silhouette: where the mass sits, how tight it is, whether there is a second peak. A p50/p99 pair cannot show a bimodal service, and a box plot (the Scatter variant) flattens it to a rectangle.
Not for: a single distribution (that is a histogram — one ridge is a ridgeline with the comparison removed); series measured in different units or on different x-ranges, which cannot share the one x-scale the type requires; time series, where each row is one value per moment rather than one distribution; or distributions so similar that the ridges are five copies of one shape, which a table of percentiles says shorter.
diff --git a/skills/diagram-design/references/type-scatter.md b/skills/diagram-design/references/type-scatter.md
index 80c44fa..c9558c0 100644
--- a/skills/diagram-design/references/type-scatter.md
+++ b/skills/diagram-design/references/type-scatter.md
@@ -115,7 +115,7 @@ What each binding buys, and what it costs to omit:
**Best for:** a full distribution where every unit deserves its own mark — one dot per item on a single shared value axis, dodged perpendicular so nothing overlaps. Use when the *shape* of the crowd and its outliers are the story a summary number would hide: the shipped example plots 138 per-request latency samples for one endpoint, and the point of the figure is that a healthy median and an ugly p99 are the same dataset.
-Not for: two variables (that is the parent scatter); comparing distributions across many groups (facet, or reach for a ridgeline); more than ~300 items (the packing outgrows the band — bin into a histogram); or a handful of values (below 20 there is no distribution to swarm, and a table says it shorter).
+Not for: two variables (that is the parent scatter); comparing distributions across many groups (facet, a ridgeline, or the **box plot variant** below); more than ~300 items (the packing outgrows the band — bin into a histogram); or a handful of values (below 20 there is no distribution to swarm, and a table says it shorter).
#### Layout conventions
@@ -184,6 +184,82 @@ What each binding buys, and what it costs to omit:
- Two dots wearing the same `data-name`, or an empty one: a name that identifies two marks identifies neither.
- An unbound visible string: a label or an axis tick with no attribute stating the same thing.
+### Box plot
+
+**Best for:** comparing the *shape* of a few distributions when the five-number summary is the story — one box per group on a single shared value axis. Use it when a median would hide the spread, and when drawing every unit (the beeswarm) would hide the comparison: the shipped example plots per-request latency for five services, and the point of the figure is that Checkout's median still looks survivable while its box already runs 80–200 ms.
+
+Not for: two continuous variables (that is the parent scatter); one distribution of individuals (that is the **beeswarm variant**); the silhouette of many distributions (that is the **ridgeline** on Line); a single number per category (that is a bar).
+
+#### Layout conventions
+
+- **Orientation:** horizontal only. Rows stack downward and the value axis runs left → right; a vertical box plot forces rotated category labels, which this variant does not.
+- **Same plot frame as the parent:** value axis at `y=420` inside `0 0 1000 500`. Category labels take a 160px left margin (right-aligned at `x=148`, `node-name` role 11px 600), so the scale starts at `x=160`. The shipped example uses `x = 160 + 2·ms` on a 0–400 domain.
+- **Series count: 3–8.** Below 3 a table says it shorter; above 8 split an overview from per-series detail.
+- **One box per series**, height 32px, centred on the row. Paper underlay immediately beneath so gridlines do not show through the translucent fill.
+- **Tukey fences, not the theoretical fence:** whiskers run to the last inlier (`data-wlo` / `data-whi`) inside `q1 - 1.5·IQR` and `q3 + 1.5·IQR`, with 16px caps. Outliers are `r=4` dots strictly outside those whiskers and fences, bound with `data-x` on the circle — never `data-value`, which is the beeswarm contract.
+- **Median** is a vertical `ink` line through the box at `data-q2`, 1.5px. It is the only mark that may sit on the `ink` token at full strength; the box fill stays a tint.
+- **Labels:** the category name at the left of its row, bound with `data-name`. Value-axis ticks are bound with `data-tick="x"` and `data-value`. The category axis has no scale to tick.
+- **4px grid** applies to the designed constants — axis rule, gridlines, tick baselines, legend rows, box height, row centres. Positions on the value axis are data-scaled and exempt.
+
+#### Colour
+
+- **One accent series, and one muted treatment for everyone else.** The shipped example accents Checkout — the IQR that will page — not the series with the most outliers.
+- **Fill weight, not hue, carries the pairing.** Non-focal boxes use `muted @ 0.15` fill + `muted` stroke; the focal box uses `accent @ 0.12` fill + `accent` stroke. Outliers inherit their series' stroke. The median stays `ink` on every row so it does not compete with the focal fill.
+- **The value axis is exact and shared.** Crowded boxes mean the summaries really are close; never nudge a box along the value axis to open up space.
+
+#### Honest-data rule
+
+**The five-number summary is ordered, and every mark sits on one linear scale.** `scripts/verify-box-plot.py` gates it.
+
+- **`wlo ≤ q1 ≤ q2 ≤ q3 ≤ whi`.** A median outside its box, or a whisker that grows inward, is not a five-number summary.
+- **Box left is q1, box right is q3, median is q2, whiskers are wlo/whi.** Width encodes the IQR — never pad a box to fit a label.
+- **Outliers sit strictly outside the whiskers and the Tukey fences.** Drawing an inlier as a dot, or parking an outlier on the fence, hides the tail.
+- **Linear scale only, from a stated floor.** The shipped example includes zero. A truncated axis inflates every box the same way a truncated bar does.
+- **Round once, then draw from the rounded number**, so the declared value and the drawn geometry are two statements of one number.
+
+#### Declaring the values
+
+**Every series is bound to the five numbers it encodes.** `data-q1` on a `<g>` is the box-plot contract — deliberately not `data-value` on a `<circle>` (beeswarm), `data-size` (bubble), `data-series` (slopegraph) or `data-ranks` (bump), so no sibling checker claims a box-plot file and this one claims none of theirs.
+
+```svg
+<!-- One series. x = 160 + 2·ms. Category y is a label rail. -->
+<g data-name="Checkout" data-q1="80" data-q2="120" data-q3="200"
+ data-wlo="40" data-whi="280">
+ <line data-role="whisker-lo" x1="240" y1="216" x2="320" y2="216"/>
+ <line data-role="whisker-hi" x1="560" y1="216" x2="720" y2="216"/>
+ <rect data-role="box" x="320" y="200" width="240" height="32" rx="2"
+ fill="{accent @ 0.12}" stroke="{accent}" stroke-width="1.2"/>
+ <line data-role="median" x1="400" y1="200" x2="400" y2="232"/>
+ <circle data-outlier="Checkout" data-x="388" cx="936" cy="216" r="4"/>
+</g>
+<text data-tick="x" data-value="200" x="560" y="440">200</text>
+```
+
+What each binding buys, and what it costs to omit:
+
+| Binding | Without it |
+|---|---|
+| `data-q1` / `data-q2` / `data-q3` / `data-wlo` / `data-whi` on the group | A nudged box could not be caught — the drawn geometry would be the only statement of the summary. |
+| `data-role="box"` / `"median"` / `"whisker-lo"` / `"whisker-hi"` | The checker could not tell a gridline from a whisker, or a paper underlay from the IQR. |
+| `data-x` on an outlier circle | `data-value` on a circle is the beeswarm contract; using it here would put every box-plot file inside `verify-beeswarm.py`. |
+| `data-name` on the group and its category label | Two labels exchanged between rows rename both series, with every number still correct in isolation. |
+| `data-tick` / `data-value` on a tick | The printed axis could be relabelled wholesale — every box honestly placed on a scale the axis lies about. |
+
+`scripts/verify-box-plot.py` derives the value scale from the summaries themselves, requires the five-number order, holds every box, median, whisker and outlier to that scale, refuses an outlier inside the whiskers, caps the accent at one series (read through `var()`, `hsl()` and class, id or attribute selectors), refuses a bound mark hidden by `display`, `visibility` or `opacity`, and checks every bound tick against the mark it describes; `scripts/test-verify-box-plot.py` proves each check in both polarities and pins the sibling scope treaty in both directions.
+
+**Nothing may position a mark except its own attributes.** The checker reads raw `x`/`width`/`x1`/`cx` and `y`/`cy`, so anything applied afterwards invalidates the check that passed. Every carrier is refused — the `transform` attribute, an inline `style="…"`, and a rule in a `<style>` block — on a series group, on a box, on a bound label or tick, or on an ancestor `<g>`/`<svg>`. Bake the offset into the coordinates.
+
+#### Anti-patterns
+
+- Moving a box along the value axis to open up space — the type's one unforgivable error.
+- A median outside its box, or whiskers that grow inward.
+- Parking an outlier on the fence, or drawing an inlier as a dot.
+- A hue per series instead of one muted treatment plus a single accent.
+- `data-value` on an outlier circle (that is the beeswarm contract).
+- Positioning a mark, a bound label, a tick or an ancestor group from CSS.
+- Two series wearing the same `data-name`, or an empty one.
+- An unbound visible string: a category label or an axis tick with no attribute stating the same thing.
+
## Examples
- `assets/example-scatter.html` — minimal light
@@ -195,3 +271,6 @@ What each binding buys, and what it costs to omit:
- `assets/example-beeswarm.html` — beeswarm, minimal light
- `assets/example-beeswarm-dark.html` — beeswarm, minimal dark
- `assets/example-beeswarm-full.html` — beeswarm, full editorial
+- `assets/example-box-plot.html` — box plot, minimal light
+- `assets/example-box-plot-dark.html` — box plot, minimal dark
+- `assets/example-box-plot-full.html` — box plot, full editorial