← 提示词库 Meta/muse-agent/skills/artifacts/references/charts.md 原文 md
🌐 中英双语对照

description: Building a chart on any surface: where its numbers come from, how data maps to marks, and the technique each surface needs.

Charts / 图表

Read this before writing any chart, on any surface. Decide one thing first: is
the chart a rendered image placed on a fixed page, or live elements in a page
that reflows? That choice picks your technique section below. The data and
encoding rules apply everywhere.

在为任何承载面编写任何图表之前,先阅读本文。首先要决定一件事:图表是放置在固定页面上的渲染图片,还是页面中会随回流(reflow)变化的活性元素?这一选择决定你使用下文哪个技术章节。数据规则与编码规则适用于所有场合。

Where the numbers come from / 数字从何而来

Every displayed number is computed from the plotted data. That covers
captions, headings, stat tiles, annotations, and summary lines; superlatives
("peak", "highest", "fastest-growing"), which come from an argmax over the
series, never from memory; comparisons and counts stated in prose ("up 40%",
"eight above the threshold"); and deltas, whose two endpoints must both exist
in the dataset. A literal typed into prose drifts the moment the data changes.
Never floor or cap a displayed statistic: max(22, computed) guarantees a
number, not a fact. Never claim a reconciliation you did not compute.

每一个显示出来的数字都必须由所绘制的数据计算得出。 这涵盖图注、标题、统计卡片、注释和汇总行;涵盖最高级表述("峰值"、"最高"、"增长最快")——它们来自对序列取 argmax,绝不出自记忆;涵盖行文中给出的比较与计数("上涨 40%"、"超出阈值八个");也涵盖差值——其两个端点必须都存在于数据集中。写进行文的字面量在数据一变时就发生漂移。绝不对显示的统计量做下限或上限截断:max(22, computed) 保证的是一个数字,而不是一个事实。绝不声称做了你没有计算过的核对。

【评论】该节把"显示的每个数字必须能由所绘数据复现"立为硬性约束,并点名 Math.random() 与写死字面量两类典型出错源,属于数据可信性方面的防护设计。

Totals and shares: compute a total from the parts shown beside it, never from
a different source than the parts. Percentages share one denominator and the
parts must account for the whole; if they sum to 90%, a part is missing or the
total is wrong, and the artifact says which. State a count only if it matches
what you drew. Name the remainder; an unlabeled slice is unreadable.

总计与占比:总计要从其旁边展示的各部分计算得出,绝不用与各部分不同的来源。百分比共用同一个分母,且各部分必须覆盖整体;若合计只有 90%,说明缺了一个部分或总计有误,工件上要写明是哪种情况。只有与你绘制的内容相符时才能给出计数。要为剩余部分命名;没有标签的扇区是无法解读的。

How data maps to marks / 数据如何映射为图形标记

These rules apply on every surface. Where you hand-author the chart they are
the arithmetic you are about to write; where a library computes them, check
its output, because library defaults happily draw a truncated baseline or an
axis that clips your data.

这些规则适用于每个承载面。在你手工编写图表时,它们就是你要亲手写下的算术;在由库计算时,要检查其输出,因为库的默认设置会很自然地画出被截断的基线或裁掉数据的坐标轴。

Axes:

坐标轴:

Labels:

标签:

Legends and annotations:

图例与注释:

Data shape:

数据形态:

Technique by surface / 按承载面区分的技术

Slide deck / 幻灯片

PDF or printed document / PDF 或印刷文档

Self-contained page with no build step / 无构建步骤的自包含页面

Covers runtime: static and any live page built without a bundler.

覆盖 runtime: static 以及任何不经打包器构建的活性页面。

Web artifact on the TypeScript runtime / TypeScript 运行时上的 Web 工件

Before you hand it over / 交付之前

Re-derive each headline figure from the source and compare it to what the
artifact displays: the total, the percentages, the named extreme, any growth
figure, any count you state. A number you cannot reproduce from the data is
wrong, and the fix is the number, not the caption. Then read the artifact as
its reader will, starting from first load with no interaction: a chart that
only appears after a click has not been delivered.

从数据源重新推导每个头条数字,并与工件所显示的内容比对:总计、百分比、点名的极值、任何增长数字、你陈述的任何计数。一个无法从数据中复现的数字就是错的,要修正的是数字,而不是图注。然后以读者的视角阅读工件,从首次加载、无任何交互开始:需要点击之后才出现的图表,等于没有交付。