|
|
2 bulan lalu | |
|---|---|---|
| .. | ||
| cases | 2 bulan lalu | |
| README.md | 2 bulan lalu | |
| skeleton.html | 2 bulan lalu | |
Distilled from a 14-page Apple-M-series AI deployment analysis trace (cover + 3 parts + conclusion, 8 Chart.js charts). Playwright HTML+CSS, A4 portrait, chart-rich report driven by Chart.js v4 from CDN. Use this when the source content is table- and number-heavy and you want the PDF to feel like an Apple-style data brief, not a Word dump of the markdown.
Pick a different template if the source has < 4 quantitative tables / ≤ 1 chart-able dataset
(use multi-article-aggregator or the token pipeline) or is purely prose (use
multilang-research-report).
Playwright / Chrome headless HTML+CSS → PDF, with Chart.js rendered in-browser before the print snapshot. Does NOT use the token pipeline.
Why not the token pipeline:
Architecture: a single self-contained report.html (CSS + Chart.js init scripts inlined) +
Chart.js loaded from cdn.jsdelivr.net → Chrome headless with --virtual-time-budget=15000 → PDF.
PROLOGUE · 引言 eyebrow + section-line + lead paragraph + 4 KPI cards
summarizing the questions answered).PART NN · 标题 eyebrow. Each part has 2–4 H3
subsections; each subsection mixes:data table for full-fidelity reference,insight callout for the takeaway.conclusion cards, then 3 takeaway rows, then a footer-meta block with
references).Palette (Apple-minimal tech tone — swap for the subject domain):
#1d1d1f (body text, KPI value)#424245 / #6e6e73 / #86868b (descriptors / muted)#fff / Card-mute #f5f5f7 / Hairline #e5e5ea / #d2d2d7#007AFF (Apple blue — section-line, chart-title bar, primary bar)#5AC8FA cyan / #007AFF blue / #5e5ce6 indigo / #34a853 green /
#FF9500 orange (use also for the second axis line)#c62828/#ffebee · warn #e65100/#fff3e0 · ok #2e7d32/#e8f5e9
· good #1565c0/#e3f2fd · best #6a1b9a/#f3e5f5linear-gradient(135deg, #0a1628 0%, #1d3557 50%, #2a5298 100%) with two radial
halo blobs (cyan top-right, violet bottom-left).Typography (system stack — keeps render fast, no font shipping):
font-family:
-apple-system,
BlinkMacSystemFont,
'SF Pro Display',
'PingFang SC',
/* Simplified Chinese — keep for CN reports */ 'Helvetica Neue',
Arial,
sans-serif;
-webkit-font-smoothing: antialiased@page {
size: A4 portrait;
margin: 14mm 12mm;
}
* {
-webkit-print-color-adjust: exact;
print-color-adjust: exact;
}
.page-break {
page-break-after: always;
}
.avoid-break {
page-break-inside: avoid;
} /* wrap every chart-card */
See skeleton.html (~520 lines self-contained — embeds every component primitive:
cover, KPI grid, chart cards for 8 chart types, data table with pill badges, versus card, recommend
triple, dark conclusion cards, takeaway rows, timeline strip).
Quick start:
cp templates/data-viz-report/skeleton.html /tmp/report/page.html
# Edit:
# 1. <!-- REPORT_TITLE --> / <!-- REPORT_SUBTITLE --> / cover meta stats
# 2. :root accent + cover gradient (subject-domain match)
# 3. Each <!-- SECTION_NN --> block: title, lead, KPI numbers
# 4. Chart datasets in the bottom <script> (labels + numbers only)
# 5. Drop chart cards / KPI cards you do not need; keep the wrapper
# classes intact.
# Render with Chrome headless — must give Chart.js time to draw.
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \
--headless=new --disable-gpu --no-sandbox --hide-scrollbars \
--virtual-time-budget=15000 \
--run-all-compositor-stages-before-draw \
--no-pdf-header-footer \
--print-to-pdf="/tmp/report/out.pdf" \
"file:///tmp/report/page.html"
# OR via the project's renderer (drives Playwright + same delays):
node packages/local-runtime/assets/skills/pdf/scripts/render_html.cjs \
/tmp/report/page.html /tmp/report/out.pdf
3nm⊃2; (intent: 3nm²) renders the literal
characters ⊃2; in print. For superscripts, paste the actual unicode (², ⁺, ™) or write the
word ("二代", "v2"). Do a final search for ⊃ / &sup / & in the HTML before rendering.--virtual-time-budget=15000 (or Playwright
waitForFunction), Chrome snapshots the page before charts paint and you get blank boxes. Also
disable Chart.js animation in JS: Chart.defaults.animation = false; — animated charts can also
be captured mid-frame.scales.x.type: 'logarithmic' and call it out in the chart sub-title — the log axis itself is the
message.position. Every secondary axis needs
{ position: 'right', grid: { display: false } } or it overlaps the primary.page-break-inside: avoid only works on a wrapped container. The template wraps every chart
in .chart-card.avoid-break. Charts placed directly under a section header without the wrapper
will split across pages and look broken.-webkit-print-color-adjust: exact; print-color-adjust: exact; on
*, chip background gradients (cover, KPI cards, dark conclusion) all desaturate. Apply the rule
to the universal selector, not just body.(), :, / in narrow
columns force line wrap. Use half-width (), :, / inside table cells; keep full-width in body
prose.multilang-research-report: expand content (add a
"三大核心收获" takeaway list, add a footer-meta references block) rather than shrinking margins.cdn.jsdelivr.net is the default; if the renderer runs offline, vendor
chart.umd.min.js next to the HTML and load it with a relative
<script src="chart.umd.min.js"></script>.Required placeholders:
<!-- REPORT_TITLE --> / <!-- REPORT_SUBTITLE --> — cover hero copy.<!-- COVER_TAG --> — the eyebrow chip ("DEEP RESEARCH · 2026").<!-- META_STAT_N_NUM --> / <!-- META_STAT_N_LABEL --> — three cover stat chips (entity counts
/ questions / sources).--accent: <!-- ACCENT_HEX --> — the section-line / chart-title / primary-bar color (CSS
variable).SECTION: <!-- SECTION_NUM -->, <!-- SECTION_TITLE -->, <!-- SECTION_LEAD -->, an
array of KPI tuples (label, value, unit, desc), and one or more chart datasets.id, type, labels, datasets, axes config.Optional sections (drop or duplicate freely):
Structural invariants (do not break):
page-break-after: always.chart-card is wrapped in .avoid-break.<script> at the bottom initializes every chart in
document order.Chart.defaults.animation = false is set globally.pill-bad/warn/ok/good/best); custom
colors break the legend.Diversify every run. The §4 baseline (Apple navy gradient cover + #007AFF accent) is the
trace's rendition of one specific subject (consumer hardware). Re-skin to the subject domain every
time:
| Subject | Cover gradient | Accent | Data palette feel |
|---|---|---|---|
| Consumer hardware / Apple-adjacent | navy → blue | #007AFF |
cool blues + indigo |
| Finance / market data | charcoal → emerald | #0c8a5d |
greens + amber + slate |
| Healthcare / pharma | teal → ivory | #0a7488 |
teal + coral + sand |
| Energy / industrial | graphite → ember | #d4621a |
ochre + steel + brick |
| AI / research lab | violet → midnight | #7c3aed |
violet + cyan + lime |
| Sustainability / ESG | forest → khaki | #3f7d3f |
leaf + earth + sky |
Two reports on different subjects must read as two different publications — same primitives (cards, chart cards, pills, conclusion blocks), different chrome (gradient, accent, data palette, eyebrow wording, optional sections kept vs dropped). Reusing the navy/blue across every report defeats the whole point of using HTML.