@datafe-open/markdown-chart

中文文档
0.4.1发布于 2026/10/31MITTypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 3.6万

Framework-neutral registry and lifecycle controller for JSON charts in Markdown

原始使用文档

@datafe-open/markdown-chart

Framework-neutral renderer registry, canonical markdown-chart fence router, strict JSON parser, and one-container chart lifecycle controller. Canonical inline datasets and renderer-materialized referenced datasets receive a built-in Chart/Data switch and bounded data table. The switch uses accessible chart/table icons and Qwen Code WebShell-inspired card styling. Hosts can override --markdown-chart-background, --markdown-chart-subtle-background, --markdown-chart-accent, and --markdown-chart-accent-foreground. The selected Chart/Data icon foreground falls back to --markdown-chart-background, then #ffffff, so hosts can pair a custom accent background with a contrasting foreground. See Third-party notices for source attribution and license details.

Renderers may expose a title through getTitle(parsed). The core trims that value and creates a title element only when it is non-empty; it never supplies a fallback title. The Chart/Data controls remain right-aligned when no title is present, and the chart keeps 8px of vertical spacing from the toolbar.

Canonical envelopes keep default data and optional named datasets separate from renderer-owned spec. parseMarkdownChartEnvelope() exposes validated inline or referenced table, graph, or hierarchy ChartData objects and passes both forms to the selected renderer. The shared Chart/Data view inspects the default data; renderers own the presentation of any selected named datasets.

materializeChartData() is the shared renderer-neutral ref boundary. Hosts provide ResolveChartDataRef and optional validation; core forwards the opaque ref, declared shape, and abort signal; validates returned scalar rows, nodes/links, or nested children and explicit limits; and returns inline data. Graph receives Nodes/Links subviews, while hierarchy receives a flattened path/depth/value/derived-total table. It does not select a transport, fetch, authorize, or interpret any ref scheme.

Renderers can return preferredHeight for a bounded, vertically scrollable canvas or renderError for a chart-specific constraint failure. A render error skips mount but preserves the materialized Data view; malformed JSON/source and runtime failures remain fatal.

Dynamic renderer parse contexts expose normalized language and the optional original rawLanguage first token. Adapters should preserve rawLanguage when a dynamic fence embeds a case-sensitive payload such as a file path.

ChartRenderRequest.streaming is block-level pending state. Markdown adapters defer only an unterminated tail fence; completed blocks remain mounted while the surrounding document continues streaming. ChartController renders a visible loading state while a block is pending and while parsing, materialization, or runtime mounting is in flight. Set ChartRenderRequest.loadingLabel to localize the default text. Custom Markdown adapters that render isolated blocks can use findUnclosedMarkdownFence to identify the active tail fence without duplicating fence parsing.

Set ChartRenderRequest.labels to localize chart accessibility labels, the Chart/Data controls, empty-data text, truncation notice, and adapter error fallbacks. MarkdownChartLabelOverrides is partial; omitted entries retain the exported DEFAULT_MARKDOWN_CHART_LABELS. Framework adapters expose the same labels object.

ChartRenderRequest.referenceActions is a renderer-neutral host boundary for clickable references. Core only forwards { rendererId, reference: { ref, label } }; it does not parse refs, authorize access, fetch content, navigate, or create a panel. Hosts can hide unsupported references with canOpen and handle accepted clicks with open.

版本与发布记录

@datafe-open/markdown-chart 共发布 28 个版本,首次发布于 2026/07/17;过去 12 个月发布了 28 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.4.1latest2026/10/3110 天前
0.4.02026/10/2220 天前
0.3.42026/09/221 个月前
0.3.32026/09/211 个月前
0.3.22026/09/201 个月前
0.3.12026/09/181 个月前

关于 @datafe-open/markdown-chart 的常见问题

@datafe-open/markdown-chart 是什么?

Framework-neutral registry and lifecycle controller for JSON charts in Markdown

如何安装 @datafe-open/markdown-chart?

在项目目录运行 npm install @datafe-open/markdown-chart,或使用 pnpm add / yarn add / bun add。

@datafe-open/markdown-chart 支持 TypeScript 吗?

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

@datafe-open/markdown-chart 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@datafe-open/markdown-chart 可以商用吗?

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

@datafe-open/markdown-chart 的下载量有多少?

根据 npm 官方下载统计,@datafe-open/markdown-chart 在 2026/10/12 – 2026/11/10 这 30 天内被下载 36,467 次,日均约 1,216 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@datafe-open/markdown-chart 还在维护吗?

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