For AI agents: the complete documentation index is available at https://lazygophers.github.io/pamphlet/llms.txt, the full documentation bundle is available at https://lazygophers.github.io/pamphlet/llms-full.txt, and this page is available as Markdown at https://lazygophers.github.io/pamphlet/write/diagrams/chart.md.
  • 简体中文
  • 数据图表

    这是什么

    一小张数值表画成柱状图或折线图。

    什么时候用

    展示趋势或对比——Mermaid 的 xychart-beta 能画,但它的颜色不跟主题走,会报 DIAG-304。

    怎么写

    Pamphlet 自己的写法——先列声明、再列关系,十七种图共用这副骨架:

    :::chart[月度请求量]{type=bar}
    points:
      一月 : 120
      二月 : 180
      三月 : 150
    :::

    这一种 Mermaid 画不了,所以没有「另一种写法」——它的 SVG 由 Pamphlet 自己算布局、自己生成。

    出来是什么样

    编译时就画好内联进产物,读者那边不下载任何绘图库、也不联网。颜色走那六个图表变量(--pf-diagram-bg / line / fill / text / accent / muted),所以换主题时它跟着变。

    文字宽度是按字符估算的(中日韩字符算一个字宽,其余算 0.55),不量真实字体——换来的是这一种图不需要浏览器也能编译。

    坑

    • {type=bar} 是柱状图,{type=line} 是折线图,写别的报 DIAG-307
    • 每行 名字 : 数值,数值不是数字会报 DIAG-306
    • 纵轴的最大值就是数据里的最大值,不做「取整到 200」这种美化