dataviz
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseData 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 . To target your brand, read that file's structure and substitute its values - touch nothing else.
references/palette.mdThe 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.
- 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 - 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 - VALIDATE the palette - run the script, don't reason about Delta E. (relative to this skill's base directory - or load it as
node scripts/validate_palette.js "<hex,hex,...>" --mode lightin the chart's own page, where it reads<script type="module">offdata-paletteand logs a<body>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 forconsole.tablewith that mode's surface.--mode dark - 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 - 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 - 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.
- 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 - it is the catalog of what goes wrong. If your chart matches an entry, it's wrong.
references/anti-patterns.md颜色放在最后。大多数糟糕的图表都会先选颜色。
- **选择形式。**数据要表达什么——量级、身份、极性、单个核心指标,还是随时间的变化?数据任务决定图表类型,有时答案并不是图表(而是 stat tile 或 hero number)。->
references/choosing-a-form.md - **按照颜色承担的任务分配颜色。**Categorical(身份)、sequential(量级)、diverging(极性)或 status(状态)——每种用途都有各自规则。Categorical hue 必须按固定顺序分配,绝不循环使用。->
references/color-formula.md - 验证 palette——运行脚本,不要凭感觉推断 Delta E。(相对于本 skill 的 base directory 运行——也可以在图表自己的页面中将其作为
node scripts/validate_palette.js "<hex,hex,...>" --mode light加载;此时它会从<script type="module">读取<body>,并输出data-palette报告)。脚本会针对 lightness band、chroma floor、相邻色对的 CVD separation、normal-vision floor 和 contrast 返回通过/失败结果。继续之前,请修复所有 FAIL 项。使用对应模式的 surface,以console.table重新运行。--mode dark - **应用 mark specs 与间隔。**使用细窄 mark、数据末端采用 4px 圆角并锚定基线、2px 线、>=8px marker;填充之间(堆叠分段和相邻柱形同样如此)留出 2px surface 间隔;重叠 mark 外加 2px surface ring;酌情添加直接标签。->
references/marks-and-anatomy.md - **添加 hover 层——默认必须添加。**HTML/SVG 图表是交互式的:折线图/面积图应提供 crosshair+tooltip,柱形图/点图/单元格图应提供逐 mark 的 hover tooltip。唯一可以省略的形式是不含 plot 的纯 stat tile。命中区域应大于 mark;筛选器统一排列在图表上方一行。->
references/interaction.md - **执行最终无障碍检查。**当 series 数量 >= 2 时始终提供 legend,数量 <= 4 时还要添加直接标签(单一 series 不需要 legend box,由标题说明其含义),确保身份绝不只依赖颜色;提供 table view;dark mode 必须经过专门选择——使用同一组 ramps 中为 dark surface 单独选取并验证过的 step,而不是自动反转;针对 CVD、打印和强制颜色场景提供 texture。
- **渲染并亲自检查。**Validator 检查的是颜色,而不是布局——打开或截取输出结果,检查标签碰撞、几何结构和溢出问题后,才能认为完成。
然后将结果与 对照检查——该文件列出了常见错误。如果图表符合其中任何一项,就说明它有问题。
references/anti-patterns.mdNon-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 cut series or facet instead - see check 4. A contrast WARN obligates visible labels or a table view - it is not dismissable.
--pairs all - 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 不能豁免这一项);在 下,应改为删减 series 或使用 facet——参见检查 4。Contrast WARN 要求提供可见标签或 table view,不能忽略。
--pairs all - 使用细窄 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| Parameter | What the system provides |
|---|---|
| Ramps | the hue scales (named steps) the palette draws from |
| Categorical theme | the fixed hue order (a named theme); default + alternates |
| Sequential hue | the default single hue for magnitude |
| Diverging pair | two warm/cool poles + a neutral midpoint |
| Status palette | good / warning / serious / critical - steps distinct from categorical |
| Texture fill | one directional hand-drawn fill, used at 45° / 135° |
| Surfaces | light & dark chart-surface colors (the validator needs these) |
| Filter controls | date-range & dimension controls (behavioral spec in |
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| 参数 | 系统提供什么 |
|---|---|
| Ramps | Palette 取色所用的 hue scale(具名 step) |
| Categorical theme | 固定 hue 顺序(具名 theme);包含默认值和备选值 |
| Sequential hue | 用于表达量级的默认单一 hue |
| Diverging pair | 两个冷暖两极色 + 一个中性中点 |
| Status palette | good/warning/serious/critical——其 step 与 categorical 明确区分 |
| Texture fill | 单方向手绘填充,用于 45°/135° |
| Surfaces | light 和 dark 的 chart-surface 颜色(validator 需要这些值) |
| Filter controls | 日期范围和维度控件(行为规范见 |
接入新系统时:填写这些行,将对应的 ramps 输入 validator,并让它把每个 slot 对齐到最接近的合格 step。结构和规则保持原样。
Reference files
参考文件
| File | What it answers |
|---|---|
| Which chart type / is it even a chart? |
| The four jobs, the six checks, snap-to-passing |
| Mark specs, spacers, labels, figures, hero number |
| Tooltips & hover, filters & time ranges |
| The pieces a chart is made of - build each in plain HTML |
| What goes wrong - check every chart against this |
| The reference palette instance - every parameter, filled in; swap for your brand's |
| Runnable six-checks validator (run it; don't eyeball) |
| 文件 | 回答什么问题 |
|---|---|
| 应使用哪种图表类型?这究竟是不是图表? |
| 四类用途、六项检查,以及如何调整至通过 |
| Mark specs、间隔、标签、图形和 hero number |
| Tooltip 与 hover、筛选器和时间范围 |
| 图表由哪些部分组成——使用纯 HTML 构建每个部分 |
| 哪些地方会出错——必须对照检查每个图表 |
| 参考 palette 实例——所有参数均已填写,可替换为你的品牌配置 |
| 可运行的六项检查 validator(请运行它,不要凭肉眼判断) |