comark-charts

中文文档
0.9.0发布于 2026/11/03MITTypeScriptES Module构建来源已验证

Charts from a Markdown table, drawn to SVG while parsing, that copy as a PNG or as data: bars, stacked bars, lines, areas, scatter plots, dumbbells, waterfalls, pies, gantt charts, and sankeys. The table stays in the page, so people see the chart and agen

原始使用文档

comark-charts

npm version npm downloads license docs

Charts from a Markdown table, drawn to SVG while parsing, that copy as a PNG or as data. The table stays under the chart, so people see the chart and agents read the numbers. A Comark plugin for HTML, Vue, React, and Svelte.

pnpm add comark @comark/html comark-charts
import { createHtmlRenderer } from "@comark/html";
import charts, { components } from "comark-charts/html";

const render = createHtmlRenderer({ plugins: [charts()], components });
::chart{type="line" title="Coffee cups and commits, per month (r = 0.99)"}
| month | coffee cups | commits |
| --- | --: | --: |
| 2026-04 | 820 | 610 |
| 2026-05 | 890 | 640 |
| 2026-06 | 905 | 652 |
::

Put one table between ::chart and ::: a header row, then one row per point. The first column is x, and every other column is a series of numbers, named by its header.

PropWhat it does
typebar, stacked, line, area, scatter, dumbbell, waterfall, pie, gantt, or sankey. Default bar.
xThe column along the x axis. Default the first.
yThe columns to draw, separated by commas. Default every column but x.
titleThe chart's caption, and its name for screen readers.
labelsPrints the numbers on the chart's bars, steps, or dots. Takes no value.
horizontalTurns bars sideways, for long names such as file paths. Takes no value.

Mark a value with a comark-annotate annotation after the table: at names the row by its x value and series its column, and the renderer draws the mark around the bar, point, or slice.

:::annotation{at="2026-05" series="commits" mark="circle" color="green"}
The espresso machine arrives.
:::

For any other chart, put a Vega-Lite spec after the table in a vega-lite block; the table is its data. The docs show the table each type expects.

The plugin adds every problem to meta.issues, so a host can reject a document before publishing it. Each issue names its chart and says how to fix it.

How it renders

Flint turns the table into a Vega-Lite spec with a house theme, and Vega draws it to SVG while parsing, on the server or at build time, so the browser runs no chart code. comark-charts/vue, /react, and /svelte place the same SVG; marks, which come from comark-annotate, show only in @comark/html.

The page holds a figure.cch with the title, the SVG, and the table folded into Data. Text, axes, and grid follow Nuxt UI's or shadcn/ui's variables and the shared --comark-* tokens, so charts switch with the page's dark mode. Series take --comark-chart-1 to -6, then Nuxt UI's --ui-chart-1 to -6, then shadcn/ui's --chart-1 to -6. The rules sit in a comark CSS layer, so any plain rule of your own wins; see the charts' Theming page.

The comark-ui agent skill covers charts; install it with vp dlx skills add onmax/comark-ui, or bundle it in your own app from comark-ui/skills/comark-ui/. vp comes with Vite+; without it, pnpm dlx takes the same arguments.

版本与发布记录

comark-charts 共发布 11 个版本,首次发布于 2026/10/21;过去 12 个月发布了 11 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.9.0latest2026/11/03今天
0.8.22026/11/021 天前
0.8.12026/11/011 天前
0.8.02026/10/312 天前
0.7.62026/10/313 天前
0.7.52026/10/303 天前

关于 comark-charts 的常见问题

comark-charts 是什么?

解析时绘制到SVG的Markdown表中的图表,复制为PNG或数据:条形图、堆叠条形图、线条、区域、散点图、哑铃图、瀑布图、饼图、甘特图和sandkeys。表格保留在页面中,因此人们可以看到图表和agen

如何安装 comark-charts?

在项目目录运行 npm install comark-charts,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:comark(^0.8.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

comark-charts 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

comark-charts 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

comark-charts 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.12.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

comark-charts 可以商用吗?

comark-charts 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

comark-charts 还在维护吗?

最新版本 0.9.0 发布于 2026/11/03(今天);至今共发布 11 个版本,其中过去 12 个月发布了 11 个;首次发布于 2026/10/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。