@graphysdk/node-renderer 1.8.1-beta.1787065194945 → 1.8.1-beta.1787132472323
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -53
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,88 +1,69 @@
|
|
|
1
1
|
# @graphysdk/node-renderer
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Render a Graphy chart to a PNG in Node.js.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
- [Provider and renderer](https://docs.graphy.dev/sdk-next/rendering/provider-and-renderer)
|
|
8
|
-
- [Quickstart](https://docs.graphy.dev/sdk-next/quickstart)
|
|
9
|
-
|
|
10
|
-
## Serverless (Lambda, Vercel, etc.)
|
|
11
|
-
|
|
12
|
-
This package is designed for ephemeral Node runtimes:
|
|
5
|
+
## Install
|
|
13
6
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
- **No temp files:** Rendering is in-memory (`Buffer` in, PNG `Buffer` out).
|
|
17
|
-
- **Inter via npm:** Default fonts load from `@fontsource/inter` at runtime using `require.resolve` (WOFF files in `node_modules`). No writable disk or checked-in TTFs required.
|
|
18
|
-
|
|
19
|
-
Host apps using Nitro, esbuild, or similar should treat `@graphysdk/node-renderer`, `@napi-rs/canvas`, and `@fontsource/inter` as **external** runtime dependencies (same as other native addons). For Nitro on Vercel, include `@fontsource/inter` in `traceDeps` so font files are copied into the function bundle:
|
|
20
|
-
|
|
21
|
-
```ts
|
|
22
|
-
traceDeps: ['@graphysdk/node-renderer', '@napi-rs/canvas', '@fontsource/inter'],
|
|
7
|
+
```bash
|
|
8
|
+
npm install @graphysdk/node-renderer @graphysdk/viz-engine
|
|
23
9
|
```
|
|
24
10
|
|
|
25
|
-
## Fonts
|
|
26
|
-
|
|
27
|
-
Text measurement and drawing use the same `@napi-rs/canvas` context with family **`Inter`** (aligned with the browser renderer).
|
|
28
|
-
|
|
29
|
-
1. **Default (automatic):** `ensureDefaultFonts()` registers Latin Inter 400 and 600 from `@fontsource/inter` on first render. Works on Vercel as long as `@fontsource/inter` is installed (declared as a dependency of this package).
|
|
30
|
-
|
|
31
|
-
2. **Optional `assets/` override:** place TTF files at `assets/Inter-Regular.ttf` and `assets/Inter-SemiBold.ttf` beside the installed package if you need custom binaries instead of Fontsource.
|
|
32
|
-
|
|
33
|
-
3. **In-memory:** pass `fonts` in `RenderOptions` or call `registerFont({ family, data: Buffer })`. Optional `weight` / `style` on `FontRegistration` are dedup-cache keys only — Skia reads metrics from the font bytes.
|
|
34
|
-
|
|
35
|
-
Without registered fonts, Skia uses built-in fallbacks; layout may differ from the browser renderer.
|
|
36
|
-
|
|
37
11
|
## Usage
|
|
38
12
|
|
|
39
|
-
### Low-level spec API
|
|
40
|
-
|
|
41
13
|
```ts
|
|
42
14
|
import { renderGraphToPng } from '@graphysdk/node-renderer';
|
|
43
15
|
import { createSpec, geom, pipe, scale } from '@graphysdk/viz-engine';
|
|
44
16
|
|
|
45
17
|
const input = pipe(createSpec({ x: 'category', y: 'value' }), geom.bar(), scale.x(), scale.y());
|
|
46
18
|
|
|
47
|
-
const png = await renderGraphToPng({ input, data }, { width: 1200, height: 800,
|
|
19
|
+
const png = await renderGraphToPng({ input, data }, { width: 1200, height: 800, colorScheme: 'light' });
|
|
48
20
|
```
|
|
49
21
|
|
|
50
|
-
|
|
22
|
+
## Docs
|
|
23
|
+
|
|
24
|
+
- [Quickstart](https://docs.graphy.dev/sdk-next/quickstart) — React apps start with [`@graphysdk/react`](https://www.npmjs.com/package/@graphysdk/react)
|
|
25
|
+
|
|
26
|
+
## GraphConfig
|
|
51
27
|
|
|
52
|
-
|
|
28
|
+
If you already have a stored chart config (`{ type, data, … }`), render it with `renderChartConfigToPng`. Check `canRenderConfigWithCanvas` first — some chart types are not supported.
|
|
53
29
|
|
|
54
30
|
```ts
|
|
55
31
|
import { canRenderConfigWithCanvas, renderChartConfigToPng } from '@graphysdk/node-renderer';
|
|
56
32
|
|
|
57
33
|
const capability = canRenderConfigWithCanvas(storedConfig);
|
|
58
34
|
if (!capability.ok) {
|
|
59
|
-
//
|
|
35
|
+
// use another export path
|
|
60
36
|
}
|
|
61
37
|
|
|
62
|
-
const png = await renderChartConfigToPng(storedConfig, { width: 1200, height: 800,
|
|
38
|
+
const png = await renderChartConfigToPng(storedConfig, { width: 1200, height: 800, colorScheme: 'light' });
|
|
63
39
|
```
|
|
64
40
|
|
|
65
|
-
|
|
41
|
+
Supported types: `column`, `columnStacked`, `columnStackedFill`, `bar`, `barStacked`, `barStackedFill`, `line`, `areaStacked`, `pie`, `donut`, `scatter`, `bubble`, `combo`.
|
|
66
42
|
|
|
67
|
-
|
|
43
|
+
Not supported: `funnel`, `heatmap`, `waterfall`, `mekko`, `table`.
|
|
68
44
|
|
|
69
|
-
|
|
70
|
-
| ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
71
|
-
| **Supported `type`** | `column`, `columnStacked`, `columnStackedFill`, `bar`, `barStacked`, `barStackedFill`, `line`, `areaStacked`, `pie`, `donut`, `scatter`, `bubble`, `combo` |
|
|
72
|
-
| **Unsupported `type`** | `funnel`, `heatmap`, `waterfall`, `mekko`, `table` (viz-engine throws) |
|
|
73
|
-
| **Canvas geoms** | Cartesian: bar, line, area, point, rule — Polar: bar (pie/donut) |
|
|
74
|
-
| **Rejected up front** | `_unstable_mapping`; `referenceLines.trendline` / `referenceLines.averageLine` |
|
|
75
|
-
| **Supported referenceLines** | `goalLine` (compiled to `geom.rule`) |
|
|
76
|
-
| **Legend display** | `pill` (color, stacked swatches, bubble/size); `direct` (series labels on panel edge) |
|
|
77
|
-
| **Lossy at compile** | Annotations, `themeOverrides`, series styles, headline numbers (see viz-engine `graph-config.converter`) |
|
|
78
|
-
| **Visual deltas vs browser** | Font metrics, anti-aliasing |
|
|
45
|
+
Annotations, theme overrides, series styles, and headline numbers may be dropped or simplified in the PNG.
|
|
79
46
|
|
|
80
|
-
`CANVAS_SUPPORTED_GRAPH_TYPES
|
|
47
|
+
The package also exports `CANVAS_SUPPORTED_GRAPH_TYPES` and `canRenderConfigWithCanvas` for checks in your own code.
|
|
81
48
|
|
|
82
|
-
##
|
|
49
|
+
## Fonts
|
|
83
50
|
|
|
84
|
-
|
|
85
|
-
|
|
51
|
+
Latin Inter 400 and 600 load automatically.
|
|
52
|
+
|
|
53
|
+
To use your own fonts, pass `fonts` when rendering or call `registerFont({ family, data })`.
|
|
54
|
+
|
|
55
|
+
## Serverless
|
|
56
|
+
|
|
57
|
+
This package uses a native canvas module. Install it as a normal dependency — do not bundle it into your function.
|
|
58
|
+
|
|
59
|
+
On Vercel with Nitro, include these in `traceDeps` so binaries and fonts are copied into the function:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
traceDeps: ['@graphysdk/node-renderer', '@napi-rs/canvas', '@fontsource/inter'];
|
|
86
63
|
```
|
|
87
64
|
|
|
88
65
|
Serves preset chart PNGs at `http://localhost:4310` (see `src/dev/server.ts`).
|
|
66
|
+
|
|
67
|
+
## Support
|
|
68
|
+
|
|
69
|
+
Questions and community help: [Discord](https://discord.gg/yGmYCjkSr).
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"headless",
|
|
13
13
|
"renderer"
|
|
14
14
|
],
|
|
15
|
-
"version": "1.8.1-beta.
|
|
15
|
+
"version": "1.8.1-beta.1787132472323",
|
|
16
16
|
"type": "module",
|
|
17
17
|
"sideEffects": [
|
|
18
18
|
"**/version.ts"
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@fontsource/inter": "5.2.8",
|
|
41
41
|
"@napi-rs/canvas": "^0.1.76",
|
|
42
42
|
"d3-shape": "^3.2.0",
|
|
43
|
-
"@graphysdk/viz-engine": "1.8.1-beta.
|
|
43
|
+
"@graphysdk/viz-engine": "1.8.1-beta.1787132472323"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@rollup/plugin-replace": "^6.0.3",
|