@ggts-sh/core

中文文档
0.48.3发布于 2026/11/06MITTypeScriptES Module构建来源已验证近 30 天下载 9197

ggts core: framework-agnostic grammar-of-graphics pipeline, scale stability, layout, and the pure SVG-string renderer.

原始使用文档

@ggts-sh/core

codecov

Grammar pipeline (stats, positions, facets, scales, layout) and pure SVG-string renderer. The main entry has no DOM — Node, edge runtimes, workers. Canvas and hit-testing live under @ggts-sh/core/dom. Pre-1.0.

bun add @ggts-sh/core     # or: npm install @ggts-sh/core

For server, CLI, and agent rendering. Svelte apps use @ggts-sh/svelte.

Quick example

Author with the builder from @ggts-sh/spec, render here:

import { registerAll, renderToSVGString, runPipeline } from "@ggts-sh/core";
import { aes, gg } from "@ggts-sh/spec";

// The barrel is side-effect-free: register the grammar explicitly (or import
// "@ggts-sh/core/render" for identity charts only).
registerAll();

const spec = gg(
  [
    { year: "1835", value: 12 },
    { year: "2026", value: 31 },
  ],
  aes({ x: "year", y: "value" }),
)
  .geomLine()
  .spec();

const svg = renderToSVGString(spec, { width: 640, height: 400 });

const model = runPipeline(spec, { width: 640, height: 400 });
// model.scene, model.scaleDecisions, model.guidePlans,
// model.advisories, model.warnings, model.candidates

For the smallest point-only headless bundle, opt into one geom family:

import { renderToSVGString } from "@ggts-sh/core/headless";
import { registerBasicPoints } from "@ggts-sh/core/headless/register";

registerBasicPoints();

Mapped colors can stay catalog-free too: call registerDefaultOrdinalColor() for the built-in palette or an explicit range. Call registerOrdinalColor() instead when the spec selects a named categorical, ColorBrewer, sequential, or Crameri scheme.

Bare PortableSpec JSON works the same way — channel mappings use { field: "col" }, not bare strings:

import { renderToSVGString } from "@ggts-sh/core";

const svg = renderToSVGString(
  {
    data: {
      values: [
        { year: "1835", value: 12 },
        { year: "2026", value: 31 },
      ],
    },
    layers: [
      {
        geom: "line",
        aes: { x: { field: "year" }, y: { field: "value" } },
      },
    ],
  },
  { width: 640, height: 400 },
);

Entries

ImportUse
@ggts-sh/coreFull grammar + temporal + SVG string
@ggts-sh/core/renderLean identity-chart surface (auto-registers basics)
@ggts-sh/core/headlessSide-effect-free headless pipeline and SVG renderer
@ggts-sh/core/headless/registerTree-shakeable basic geom/stat family registration
@ggts-sh/core/dataBundled teaching datasets for any framework
@ggts-sh/core/domBrowser canvas draw + hit index
@ggts-sh/core/temporalTemporal polyfill entry

CLI without installing this package as a library: ggts render (same pipeline, JSONL diagnostics on stderr).

Specs validate through @ggts-sh/spec. Docs: ggts.sh · Repo: github.com/ggts-sh/ggts

MIT © Liam O'Dea

版本与发布记录

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

版本发布日期距今
0.48.3latest2026/11/0610 天前
0.48.22026/11/0610 天前
0.48.12026/11/0510 天前
0.48.02026/11/0511 天前
0.47.02026/11/0313 天前
0.46.02026/11/0313 天前

关于 @ggts-sh/core 的常见问题

@ggts-sh/core 是什么?

ggts core: framework-agnostic grammar-of-graphics pipeline, scale stability, layout, and the pure SVG-string renderer.

如何安装 @ggts-sh/core?

在项目目录运行 npm install @ggts-sh/core,或使用 pnpm add / yarn add / bun add。

@ggts-sh/core 支持 TypeScript 吗?

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

@ggts-sh/core 支持 ESM 还是 CommonJS?

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

@ggts-sh/core 需要什么版本的 Node.js?

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

@ggts-sh/core 可以商用吗?

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

@ggts-sh/core 的下载量有多少?

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

@ggts-sh/core 还在维护吗?

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