dataviz

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Data Visualization

数据可视化

A chart is read by people and executed by you. This skill turns "make it look good" into a procedure with checks, so the result is right by construction rather than by taste.
The method here is design-system-agnostic. Nothing in the procedure, the form heuristic, the six checks, or the mark specs is specific to one product. A design system supplies a small set of parameters (its ramps, a categorical order, a diverging pair, a status palette, a texture, its surfaces, its filter components); the method consumes them unchanged. A validated default palette is the reference instance, fully specified in
references/palette.md
. To target your brand, read that file's structure and substitute its values - touch nothing else.
The single most important habit: the color part is computable, so compute it. Never eyeball whether a palette is colorblind-safe - run
scripts/validate_palette.js
.
图表是给人阅读的,而你是负责实现它的。此 skill 将“让它看起来好看”转化为一套带检查项的流程,使结果从构建之初就正确,而不是依赖个人品味。
**这里的方法不依赖设计系统。**流程、form heuristic、六项检查和 mark specs 均不针对某个特定产品。设计系统提供少量参数(色阶、分类顺序、发散色对、状态 palette、纹理、界面 surface 和筛选组件);本方法会原样使用这些参数。经验证的默认 palette 是参考实例,所有值均完整列于
references/palette.md
。如果要适配自己的品牌,请阅读该文件的结构并替换其中的值——不要改动其他内容。
最重要的习惯是:**颜色部分是可以计算的,所以就去计算。**绝不要凭肉眼判断 palette 是否适合色盲用户——请运行
scripts/validate_palette.js
。

The procedure - do these in order

流程——请按顺序执行

Color comes LAST. Most bad charts pick colors first.
  1. Pick the form. What is the data's job - magnitude, identity, polarity, a single headline, change-over-time? The job picks the chart type, and sometimes the answer is not a chart (a stat tile or hero number). ->
    references/choosing-a-form.md
  2. Assign color by the job it does. Categorical (identity), sequential (magnitude), diverging (polarity), or status (state) - each has one rule. Assign categorical hues in fixed order, never cycled. ->
    references/color-formula.md
  3. VALIDATE the palette - run the script, don't reason about Delta E.
    node scripts/validate_palette.js "<hex,hex,...>" --mode light
    (relative to this skill's base directory - or load it as
    <script type="module">
    in the chart's own page, where it reads
    data-palette
    off
    <body>
    and logs a
    console.table
    report). It returns pass/fail on the lightness band, chroma floor, adjacent-pair CVD separation, the normal-vision floor, and contrast. Fix anything that FAILs before continuing. Re-run for
    --mode dark
    with that mode's surface.
  4. Apply mark specs & spacers. Thin marks, 4px rounded data-ends anchored to the baseline, 2px lines, >=8px markers, a 2px surface gap between fills (stacked segments and adjacent bars alike) and a 2px surface ring on overlapping marks, selective direct labels. ->
    references/marks-and-anatomy.md
  5. Add the hover layer - by default. An HTML/SVG chart is interactive; ship a crosshair+tooltip on line/area and a per-mark hover tooltip on bar/dot/cell. The only form that skips it is a bare stat tile with no plot. Hit targets bigger than the mark; filters in one row above the charts. ->
    references/interaction.md
  6. Final accessibility pass. For >= 2 series a legend is always present and <= 4 are also direct-labeled (a single series needs no legend box - the title names it), so identity is never color-alone; a table view exists; dark mode is selected - its own steps from the same ramps, validated against the dark surface, not an automatic flip; texture is available for the CVD/print/forced-colors case.
  7. Render it and look at it. The validator checks color, not layout - open or screenshot the output and eyeball it for label collisions, geometry, and overflow before calling it done.
Then check the result against
references/anti-patterns.md
- it is the catalog of what goes wrong. If your chart matches an entry, it's wrong.
颜色放在最后。大多数糟糕的图表都会先选颜色。
  1. **选择形式。**数据要表达什么——量级、身份、极性、单个核心指标,还是随时间的变化?数据任务决定图表类型,有时答案并不是图表(而是 stat tile 或 hero number)。->
    references/choosing-a-form.md
  2. **按照颜色承担的任务分配颜色。**Categorical(身份)、sequential(量级)、diverging(极性)或 status(状态)——每种用途都有各自规则。Categorical hue 必须按固定顺序分配,绝不循环使用。->
    references/color-formula.md
  3. 验证 palette——运行脚本,不要凭感觉推断 Delta E。
    node scripts/validate_palette.js "<hex,hex,...>" --mode light
    (相对于本 skill 的 base directory 运行——也可以在图表自己的页面中将其作为
    <script type="module">
    加载;此时它会从
    <body>
    读取
    data-palette
    ,并输出
    console.table
    报告)。脚本会针对 lightness band、chroma floor、相邻色对的 CVD separation、normal-vision floor 和 contrast 返回通过/失败结果。继续之前,请修复所有 FAIL 项。使用对应模式的 surface,以
    --mode dark
    重新运行。
  4. **应用 mark specs 与间隔。**使用细窄 mark、数据末端采用 4px 圆角并锚定基线、2px 线、>=8px marker;填充之间(堆叠分段和相邻柱形同样如此)留出 2px surface 间隔;重叠 mark 外加 2px surface ring;酌情添加直接标签。->
    references/marks-and-anatomy.md
  5. **添加 hover 层——默认必须添加。**HTML/SVG 图表是交互式的:折线图/面积图应提供 crosshair+tooltip,柱形图/点图/单元格图应提供逐 mark 的 hover tooltip。唯一可以省略的形式是不含 plot 的纯 stat tile。命中区域应大于 mark;筛选器统一排列在图表上方一行。->
    references/interaction.md
  6. **执行最终无障碍检查。**当 series 数量 >= 2 时始终提供 legend,数量 <= 4 时还要添加直接标签(单一 series 不需要 legend box,由标题说明其含义),确保身份绝不只依赖颜色;提供 table view;dark mode 必须经过专门选择——使用同一组 ramps 中为 dark surface 单独选取并验证过的 step,而不是自动反转;针对 CVD、打印和强制颜色场景提供 texture。
  7. **渲染并亲自检查。**Validator 检查的是颜色,而不是布局——打开或截取输出结果,检查标签碰撞、几何结构和溢出问题后,才能认为完成。
然后将结果与
references/anti-patterns.md
对照检查——该文件列出了常见错误。如果图表符合其中任何一项,就说明它有问题。

Non-negotiables (true in every design system)

不可妥协项(每个设计系统都适用)

  • Assign categorical hues in fixed order, never cycled. A 9th series is never a generated hue - it folds into "Other," small multiples, or composite encoding.
  • One axis. Never a dual-axis chart (two y-scales). Two measures of different scale -> two charts, small multiples, or indexed to a common base. (This is the #1 chart mistake - see anti-patterns.)
  • Color follows the entity, never its rank. A filter that changes the series count must not repaint the survivors.
  • Sequential = one hue, light->dark. Diverging = two hues + a neutral gray midpoint. Never a rainbow; never a hue at the diverging midpoint.
  • Run the validator before shipping any categorical palette. CVD Delta E >= 8 is the target (OKLab x100); 6-8 is a floor that is legal ONLY with secondary encoding. A normal-vision floor below 15 is a hard FAIL - full-color readers can't tell the pair apart; re-step it on the adjacent pairlist (secondary encoding does not excuse this one); under
    --pairs all
    cut series or facet instead - see check 4. A contrast WARN obligates visible labels or a table view - it is not dismissable.
  • Thin marks; a legend always present for >= 2 series (none for one), with selective direct labels (never a number on every point); recessive grid/axes.
  • Text wears text tokens, never the series color - values, labels, and legends stay in primary/secondary/muted ink; a colored mark beside them carries identity.
  • Status colors are reserved (good/warning/serious/critical) and never reused for "series 4"; they ship with an icon + label, never color alone.
  • **Categorical hue 必须按固定顺序分配,绝不循环使用。**第 9 个 series 绝不能通过生成新色相来处理——应归入“Other”、small multiples 或 composite encoding。
  • **只能使用一个坐标轴。**绝不要使用双坐标轴图表(两个 y 轴 scale)。如果两个量度的 scale 不同,应使用两个图表、small multiples,或将它们转换为共同的基准进行索引。(这是图表的头号错误——参见 anti-patterns。)
  • **颜色跟随实体,而绝不跟随排名。**改变 series 数量的筛选器不得重新绘制保留下来的 series。
  • **Sequential 使用单一 hue,从浅到深;Diverging 使用两个 hue 加一个中性灰色中点。**绝不使用 rainbow;绝不让发散色中点带有 hue。
  • **发布任何 categorical palette 前都要运行 validator。**CVD Delta E >= 8 是目标值(OKLab x100);6-8 是底线,仅在存在 secondary encoding 时才可接受。normal-vision floor 低于 15 是 hard FAIL——正常色觉读者也无法分辨该色对;应在 adjacent pairlist 上重新取阶(secondary encoding 不能豁免这一项);在
    --pairs all
    下,应改为删减 series 或使用 facet——参见检查 4。Contrast WARN 要求提供可见标签或 table view,不能忽略。
  • 使用细窄 mark;当 series 数量 >= 2 时始终提供 legend(单一 series 不需要),并酌情添加直接标签(绝不要在每个点上标数字);grid/axis 应保持低调。
  • 文本使用 text token,绝不使用 series color——数值、标签和 legend 应使用 primary/secondary/muted ink;旁边的彩色 mark 用于表达身份。
  • Status color 是保留色(good/warning/serious/critical),绝不能重新用于“series 4”;必须搭配 icon + label,绝不能只靠颜色。

Plugging in a design system

接入设计系统

The method is invariant; only these parameters change per system. The reference instance - every value filled in - is
references/palette.md
.
ParameterWhat the system provides
Rampsthe hue scales (named steps) the palette draws from
Categorical themethe fixed hue order (a named theme); default + alternates
Sequential huethe default single hue for magnitude
Diverging pairtwo warm/cool poles + a neutral midpoint
Status palettegood / warning / serious / critical - steps distinct from categorical
Texture fillone directional hand-drawn fill, used at 45° / 135°
Surfaceslight & dark chart-surface colors (the validator needs these)
Filter controlsdate-range & dimension controls (behavioral spec in
interaction.md
)
To onboard a new system: fill those rows, feed its ramps to the validator, and let it snap each slot to the nearest passing step. Structure and rules stay as written.
方法本身保持不变;每个系统只会更改以下参数。参考实例
references/palette.md
已填入所有值。
参数系统提供什么
RampsPalette 取色所用的 hue scale(具名 step)
Categorical theme固定 hue 顺序(具名 theme);包含默认值和备选值
Sequential hue用于表达量级的默认单一 hue
Diverging pair两个冷暖两极色 + 一个中性中点
Status palettegood/warning/serious/critical——其 step 与 categorical 明确区分
Texture fill单方向手绘填充,用于 45°/135°
Surfaceslight 和 dark 的 chart-surface 颜色(validator 需要这些值)
Filter controls日期范围和维度控件(行为规范见
interaction.md
)
接入新系统时:填写这些行,将对应的 ramps 输入 validator,并让它把每个 slot 对齐到最接近的合格 step。结构和规则保持原样。

Reference files

参考文件

FileWhat it answers
references/choosing-a-form.md
Which chart type / is it even a chart?
references/color-formula.md
The four jobs, the six checks, snap-to-passing
references/marks-and-anatomy.md
Mark specs, spacers, labels, figures, hero number
references/interaction.md
Tooltips & hover, filters & time ranges
references/components.md
The pieces a chart is made of - build each in plain HTML
references/anti-patterns.md
What goes wrong - check every chart against this
references/palette.md
The reference palette instance - every parameter, filled in; swap for your brand's
scripts/validate_palette.js
Runnable six-checks validator (run it; don't eyeball)
文件回答什么问题
references/choosing-a-form.md
应使用哪种图表类型?这究竟是不是图表?
references/color-formula.md
四类用途、六项检查,以及如何调整至通过
references/marks-and-anatomy.md
Mark specs、间隔、标签、图形和 hero number
references/interaction.md
Tooltip 与 hover、筛选器和时间范围
references/components.md
图表由哪些部分组成——使用纯 HTML 构建每个部分
references/anti-patterns.md
哪些地方会出错——必须对照检查每个图表
references/palette.md
参考 palette 实例——所有参数均已填写,可替换为你的品牌配置
scripts/validate_palette.js
可运行的六项检查 validator(请运行它,不要凭肉眼判断)