@chartpng/render 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +165 -2
- package/SECURITY.md +34 -0
- package/THIRD_PARTY_NOTICES.md +253 -0
- package/bin/chartpng-render.js +2 -0
- package/dist/packages/render/cli.d.ts +1 -0
- package/dist/packages/render/cli.js +88 -0
- package/dist/packages/render/index.d.ts +61 -0
- package/dist/packages/render/index.js +79 -0
- package/dist/src/fonts/plex.d.ts +2 -0
- package/dist/src/fonts/plex.js +9 -0
- package/dist/src/lib/errors.d.ts +4 -0
- package/dist/src/lib/errors.js +9 -0
- package/dist/src/lib/maker.d.ts +90 -0
- package/dist/src/lib/maker.js +297 -0
- package/dist/src/lib/presets.d.ts +61 -0
- package/dist/src/lib/presets.js +576 -0
- package/dist/src/lib/render.d.ts +38 -0
- package/dist/src/lib/render.js +738 -0
- package/dist/src/lib/repair.d.ts +8 -0
- package/dist/src/lib/repair.js +598 -0
- package/dist/src/lib/style.d.ts +23 -0
- package/dist/src/lib/style.js +110 -0
- package/dist/src/lib/table-chart.d.ts +133 -0
- package/dist/src/lib/table-chart.js +624 -0
- package/dist/src/lib/theme.d.ts +37 -0
- package/dist/src/lib/theme.js +288 -0
- package/package.json +51 -3
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { RenderError } from './errors.js';
|
|
2
|
+
// Blue and orange first: they stay apart for colour-blind readers.
|
|
3
|
+
export const PALETTE = ['#1f5fad', '#e0712c', '#13896f', '#c99a2e', '#5d6b7a', '#c4456a', '#4ba3d9', '#7c8f3a'];
|
|
4
|
+
// Named themes: options.plugins.chartpng.theme, or theme= in the request. Each has a palette
|
|
5
|
+
// for light and one for dark backgrounds. Light and dark are picked with isDark(background), as for the ink.
|
|
6
|
+
// editorial: the series-1..3 tokens of the ChartPNG design system. mono: its ink,
|
|
7
|
+
// ink-muted, rule-strong and rule tokens on light; on dark, the light-ink token, ink-muted,
|
|
8
|
+
// the rule-strong grey and one mid grey (the light set's near-black vanishes on dark).
|
|
9
|
+
// colorblind: Okabe-Ito (Okabe and Ito, 2008); on dark its black becomes the light-ink token.
|
|
10
|
+
// vivid and ocean are ours. test/contrast.test.ts holds every colour against light and dark
|
|
11
|
+
// backgrounds, and lists the few older colours that fall short of 3:1.
|
|
12
|
+
const MONO = ['#15161a', '#585a61', '#85878c', '#d9d5ca'];
|
|
13
|
+
const OKABE_ITO = ['#0072B2', '#E69F00', '#009E73', '#CC79A7', '#56B4E9', '#D55E00', '#F0E442', '#000000'];
|
|
14
|
+
export const THEMES = {
|
|
15
|
+
default: { light: PALETTE, dark: PALETTE },
|
|
16
|
+
editorial: { light: ['#1f5fad', '#b8430f', '#585a61'], dark: ['#7aa7e6', '#f0894a', '#a2a39d'] },
|
|
17
|
+
mono: { light: MONO, dark: ['#ecebe6', '#a2a39d', '#85878c', '#6d717a'] },
|
|
18
|
+
colorblind: { light: OKABE_ITO, dark: [...OKABE_ITO.slice(0, 7), '#ecebe6'] },
|
|
19
|
+
vivid: {
|
|
20
|
+
light: ['#2f5be3', '#d9480f', '#0b8f5b', '#a626aa', '#0e8aa8', '#c92a4b', '#a16207', '#475569'],
|
|
21
|
+
dark: ['#6c8cff', '#ff8a4c', '#3ccf91', '#d675dc', '#4cc9e6', '#ff6b86', '#e6c229', '#a3aab8'],
|
|
22
|
+
},
|
|
23
|
+
ocean: {
|
|
24
|
+
light: ['#0b5394', '#0e8a8a', '#c4502a', '#4f6f9f', '#6b7f1a', '#7b5ea7', '#8a6d1c', '#5e6168'],
|
|
25
|
+
dark: ['#5aa9e6', '#4fd1c5', '#ff8f66', '#9db4d8', '#b8c76a', '#b39ddb', '#d8b45a', '#a3aab8'],
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
export const THEME_NAMES = Object.keys(THEMES);
|
|
29
|
+
// The palette a theme setting draws with. Unset means default; an unknown name is a 400.
|
|
30
|
+
export function paletteFor(theme, background) {
|
|
31
|
+
if (theme === undefined || theme === null)
|
|
32
|
+
return PALETTE;
|
|
33
|
+
if (typeof theme !== 'string' || !Object.hasOwn(THEMES, theme)) {
|
|
34
|
+
throw new RenderError(`unknown theme ${JSON.stringify(String(theme).slice(0, 40))}; valid themes: ${THEME_NAMES.join(', ')}`, 'bad_theme');
|
|
35
|
+
}
|
|
36
|
+
return THEMES[theme][isDark(background) ? 'dark' : 'light'];
|
|
37
|
+
}
|
|
38
|
+
export const PALETTE_MAX = 12;
|
|
39
|
+
// A brand palette: hex colours as a comma-separated string or an array of strings, the "#"
|
|
40
|
+
// optional (in a URL a bare # starts the fragment). Returned as lowercase #rrggbb.
|
|
41
|
+
export function readPalette(value) {
|
|
42
|
+
const items = typeof value === 'string' ? value.split(',') : Array.isArray(value) ? value : [value];
|
|
43
|
+
const colors = [];
|
|
44
|
+
for (const item of items) {
|
|
45
|
+
const hex = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(typeof item === 'string' ? item.trim() : '');
|
|
46
|
+
if (!hex)
|
|
47
|
+
break;
|
|
48
|
+
colors.push(`#${hex[1].length === 3 ? [...hex[1]].map((c) => c + c).join('') : hex[1]}`.toLowerCase());
|
|
49
|
+
}
|
|
50
|
+
if (colors.length !== items.length || colors.length < 1 || colors.length > PALETTE_MAX) {
|
|
51
|
+
const shown = (typeof value === 'string' ? value : (JSON.stringify(value) ?? String(value))).slice(0, 40);
|
|
52
|
+
throw new RenderError(`palette must be 1 to ${PALETTE_MAX} hex colours such as 1f5fad,e0712c (#rgb or #rrggbb); got ${JSON.stringify(shown)}`, 'bad_palette');
|
|
53
|
+
}
|
|
54
|
+
return colors;
|
|
55
|
+
}
|
|
56
|
+
// What a dataset is painted with: the palette setting when there is one, else the theme's.
|
|
57
|
+
// The theme is checked either way, so a typo is never silent.
|
|
58
|
+
export function resolvePalette(settings, background) {
|
|
59
|
+
const themed = paletteFor(settings.theme, background);
|
|
60
|
+
return settings.palette == null ? themed : readPalette(settings.palette);
|
|
61
|
+
}
|
|
62
|
+
// Registered in render.ts from src/fonts/plex.ts; weights 400 and 600 only. Skia
|
|
63
|
+
// takes one face per family and weight, so the latin-ext glyphs (Ł ž ş ő) live under
|
|
64
|
+
// a second family and every font string lists both: the stack falls through per glyph.
|
|
65
|
+
export const FONT_FAMILY = 'IBM Plex Sans';
|
|
66
|
+
export const FONT_EXT = 'IBM Plex Sans Ext';
|
|
67
|
+
export const FONT_STACK = `"${FONT_FAMILY}", "${FONT_EXT}"`;
|
|
68
|
+
const font = (size, weight) => ({ family: FONT_STACK, size, ...(weight && { weight }) });
|
|
69
|
+
const LIGHT = { ink: '#15161a', muted: '#5b5d63', grid: '#e7e4dc', axis: '#c9c5ba', label: '#ffffff' };
|
|
70
|
+
const DARK = { ink: '#ecebe6', muted: '#a2a39d', grid: '#2c2e33', axis: '#45484e', label: '#111215' };
|
|
71
|
+
// The watermark label: paper with a hairline on light backgrounds, a light chip on
|
|
72
|
+
// dark ones. Opaque either way, so it reads on black, white and transparent.
|
|
73
|
+
const CHIP_LIGHT = { fill: '#f5f3ee', stroke: '#d6d2c6', text: '#15161a' };
|
|
74
|
+
const CHIP_DARK = { fill: '#ecebe6', stroke: '#ecebe6', text: '#15161a' };
|
|
75
|
+
const CARTESIAN = new Set(['bar', 'line', 'scatter', 'bubble']);
|
|
76
|
+
const ROUND = new Set(['pie', 'doughnut', 'polarArea']);
|
|
77
|
+
// #rgb, #rrggbb and rgb() backgrounds darker than mid-grey get light text.
|
|
78
|
+
export function isDark(background) {
|
|
79
|
+
const bg = background.trim().toLowerCase();
|
|
80
|
+
if (bg === 'black')
|
|
81
|
+
return true;
|
|
82
|
+
let rgb = null;
|
|
83
|
+
const hex = /^#([0-9a-f]{3}|[0-9a-f]{6})$/.exec(bg);
|
|
84
|
+
if (hex) {
|
|
85
|
+
const h = hex[1].length === 3 ? [...hex[1]].map((c) => c + c).join('') : hex[1];
|
|
86
|
+
rgb = [0, 2, 4].map((i) => parseInt(h.slice(i, i + 2), 16));
|
|
87
|
+
}
|
|
88
|
+
const fn = /^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/.exec(bg);
|
|
89
|
+
if (fn)
|
|
90
|
+
rgb = fn.slice(1, 4).map(Number);
|
|
91
|
+
if (!rgb)
|
|
92
|
+
return false;
|
|
93
|
+
const [r, g, b] = rgb.map((v) => v / 255);
|
|
94
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b < 0.45;
|
|
95
|
+
}
|
|
96
|
+
export const inkFor = (background) => (isDark(background) ? DARK : LIGHT);
|
|
97
|
+
export const chipFor = (background) => (isDark(background) ? CHIP_DARK : CHIP_LIGHT);
|
|
98
|
+
const isObject = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
99
|
+
// The theme under the user's options: objects merge, anything else the user set wins.
|
|
100
|
+
export function underlay(base, user) {
|
|
101
|
+
const out = { ...base };
|
|
102
|
+
for (const [key, value] of Object.entries(user)) {
|
|
103
|
+
// Skipped, not copied: out['__proto__'] = x would re-prototype the copy, and as an own key it breaks Chart.js.
|
|
104
|
+
if (key === '__proto__')
|
|
105
|
+
continue;
|
|
106
|
+
out[key] = isObject(value) && Object.hasOwn(base, key) && isObject(base[key]) ? underlay(base[key], value) : value;
|
|
107
|
+
}
|
|
108
|
+
return out;
|
|
109
|
+
}
|
|
110
|
+
// The margins of an image meant for an inbox or a chat: roomier than the default look.
|
|
111
|
+
const OUTPUT_PADDING = { right: 20, bottom: 12, left: 16 };
|
|
112
|
+
function themeOptions(type, options, ink, named, output = false, datasets = []) {
|
|
113
|
+
const horizontal = options.indexAxis === 'y';
|
|
114
|
+
const subtitle = !!options.plugins?.subtitle?.display;
|
|
115
|
+
const header = !!options.plugins?.title?.display || subtitle;
|
|
116
|
+
const ticks = { color: ink.muted, font: font(12) };
|
|
117
|
+
// grace leaves room above the tallest bar for the value drawn on top of it.
|
|
118
|
+
const valueAxis = { grace: '8%', grid: { color: ink.grid, drawTicks: false }, border: { display: false }, ticks: { ...ticks, padding: 8, maxTicksLimit: 6 } };
|
|
119
|
+
const categoryAxis = { grid: { display: false }, border: { color: ink.axis }, ticks };
|
|
120
|
+
const base = {
|
|
121
|
+
// Room above for the last value a line labels, unless a header already gives it air.
|
|
122
|
+
layout: { padding: output
|
|
123
|
+
? { top: type === 'line' && !header ? 28 : 16, ...OUTPUT_PADDING }
|
|
124
|
+
: { top: type === 'line' && !header ? 24 : 12, right: 16, bottom: 8, left: 8 } },
|
|
125
|
+
plugins: {
|
|
126
|
+
legend: {
|
|
127
|
+
display: ROUND.has(type) || named,
|
|
128
|
+
position: ROUND.has(type) ? 'right' : 'top',
|
|
129
|
+
align: 'start',
|
|
130
|
+
labels: { usePointStyle: true, pointStyle: 'circle', boxWidth: 8, boxHeight: 8, padding: 16, color: ink.muted, font: font(12) },
|
|
131
|
+
},
|
|
132
|
+
// A report header: a bold headline, a quieter line under it, then air before the chart.
|
|
133
|
+
// Alone, the title keeps its air below: the tallest bar's value label sits there.
|
|
134
|
+
title: { align: 'start', color: ink.ink, font: font(17, '600'), padding: { top: 0, bottom: subtitle ? 4 : 20 } },
|
|
135
|
+
subtitle: { align: 'start', color: ink.muted, font: font(12), padding: { bottom: 16 } },
|
|
136
|
+
},
|
|
137
|
+
elements: {
|
|
138
|
+
bar: { borderRadius: 4, borderSkipped: 'start', maxBarThickness: 48 },
|
|
139
|
+
// Monotone on line charts: the smooth curve never swings past a point, so revenue that jumps
|
|
140
|
+
// from 0 does not dip below 0 first. Radar keeps plain tension: monotone draws no radar lines.
|
|
141
|
+
line: { tension: 0.35, ...(type === 'line' && { cubicInterpolationMode: 'monotone' }), borderWidth: 2.5 },
|
|
142
|
+
point: { radius: 0, hitRadius: 0 },
|
|
143
|
+
arc: { borderWidth: 2, borderColor: ink.label },
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
if (CARTESIAN.has(type)) {
|
|
147
|
+
base.scales = horizontal ? { x: valueAxis, y: categoryAxis } : { x: categoryAxis, y: valueAxis };
|
|
148
|
+
if (type === 'scatter' || type === 'bubble')
|
|
149
|
+
base.scales.x = valueAxis;
|
|
150
|
+
// Datasets bound to their own axes (yAxisID: 'y1') leave the default axis unused:
|
|
151
|
+
// themed, Chart.js would still draw it, empty. Style the axes the chart uses instead.
|
|
152
|
+
const scales = isObject(options.scales) ? options.scales : {};
|
|
153
|
+
for (const axis of ['x', 'y']) {
|
|
154
|
+
const style = base.scales[axis];
|
|
155
|
+
const series = datasets.filter(isObject);
|
|
156
|
+
// No series yet: the default axes still draw the labels and the grid.
|
|
157
|
+
const ids = new Set(series.length ? series.map((d) => (typeof d[`${axis}AxisID`] === 'string' ? d[`${axis}AxisID`] : axis)) : [axis]);
|
|
158
|
+
// Chart.js decides an axis from its axis option first, then its id's first letter.
|
|
159
|
+
for (const id of Object.keys(scales))
|
|
160
|
+
if (id !== '__proto__' && isObject(scales[id]) && (scales[id].axis ?? id[0]) === axis)
|
|
161
|
+
ids.add(id);
|
|
162
|
+
if (!ids.has(axis))
|
|
163
|
+
delete base.scales[axis];
|
|
164
|
+
for (const id of ids)
|
|
165
|
+
if (id !== 'x' && id !== 'y' && id !== 'r')
|
|
166
|
+
base.scales[id] = style;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (type === 'doughnut')
|
|
170
|
+
base.cutout = '62%';
|
|
171
|
+
if (type === 'radar' || type === 'polarArea') {
|
|
172
|
+
base.scales = { r: { grid: { color: ink.grid }, angleLines: { color: ink.grid }, pointLabels: { color: ink.muted, font: font(12) }, ticks: { display: false } } };
|
|
173
|
+
}
|
|
174
|
+
return base;
|
|
175
|
+
}
|
|
176
|
+
// A soft area under a single line, fading to nothing at the axis.
|
|
177
|
+
const areaFill = (color) => (context) => {
|
|
178
|
+
const { ctx, chartArea } = context.chart;
|
|
179
|
+
if (!chartArea)
|
|
180
|
+
return 'transparent';
|
|
181
|
+
const gradient = ctx.createLinearGradient(0, chartArea.top, 0, chartArea.bottom);
|
|
182
|
+
gradient.addColorStop(0, `${color}38`);
|
|
183
|
+
gradient.addColorStop(1, `${color}00`);
|
|
184
|
+
return gradient;
|
|
185
|
+
};
|
|
186
|
+
function themeDatasets(type, data, colors) {
|
|
187
|
+
const datasets = Array.isArray(data.datasets) ? data.datasets : [];
|
|
188
|
+
const single = datasets.length === 1;
|
|
189
|
+
// Several series get a legend; one without a label would read "undefined" there.
|
|
190
|
+
const named = (dataset, i) => !single && !ROUND.has(type) && dataset.label == null ? { ...dataset, label: `Series ${i + 1}` } : dataset;
|
|
191
|
+
return {
|
|
192
|
+
...data,
|
|
193
|
+
datasets: datasets.map((raw, i) => {
|
|
194
|
+
if (!isObject(raw))
|
|
195
|
+
return raw;
|
|
196
|
+
const dataset = named(raw, i);
|
|
197
|
+
if (dataset.backgroundColor != null || dataset.borderColor != null)
|
|
198
|
+
return dataset;
|
|
199
|
+
const color = colors[i % colors.length];
|
|
200
|
+
const points = Array.isArray(dataset.data) ? dataset.data.length : 0;
|
|
201
|
+
if (ROUND.has(type))
|
|
202
|
+
return { backgroundColor: colors.slice(0, Math.max(points, 1)), ...dataset };
|
|
203
|
+
if (type === 'line') {
|
|
204
|
+
// Only the last value gets a dot: that's the number people read.
|
|
205
|
+
const pointRadius = Array.from({ length: points }, (_, j) => (j === points - 1 ? 4 : 0));
|
|
206
|
+
return { borderColor: color, backgroundColor: color, pointBackgroundColor: color, pointRadius, fill: single ? { target: 'origin', above: areaFill(color) } : false, ...dataset };
|
|
207
|
+
}
|
|
208
|
+
if (type === 'radar')
|
|
209
|
+
return { borderColor: color, backgroundColor: `${color}26`, pointRadius: 0, ...dataset };
|
|
210
|
+
return { backgroundColor: color, borderColor: color, ...dataset };
|
|
211
|
+
}),
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
// Numbers on the chart itself, so a reader in an inbox needs no tooltip:
|
|
215
|
+
// on top of bars when there are few, the last point of each line, the total
|
|
216
|
+
// inside a doughnut.
|
|
217
|
+
export const valuesPlugin = {
|
|
218
|
+
id: 'chartpngValues',
|
|
219
|
+
afterDatasetsDraw(chart, _args, opts) {
|
|
220
|
+
if (!opts.show)
|
|
221
|
+
return;
|
|
222
|
+
const { ctx } = chart;
|
|
223
|
+
const type = chart.config.type;
|
|
224
|
+
const format = (n) => (typeof n === 'number' ? n.toLocaleString('en') : '');
|
|
225
|
+
ctx.save();
|
|
226
|
+
ctx.font = `600 11px ${FONT_STACK}`;
|
|
227
|
+
ctx.fillStyle = opts.color ?? LIGHT.muted;
|
|
228
|
+
if (type === 'bar') {
|
|
229
|
+
const horizontal = chart.options.indexAxis === 'y';
|
|
230
|
+
const visible = chart.data.datasets.filter((_, i) => chart.isDatasetVisible(i));
|
|
231
|
+
if (visible.length > 2 || (chart.data.labels?.length ?? 0) > 12)
|
|
232
|
+
return ctx.restore();
|
|
233
|
+
chart.data.datasets.forEach((dataset, i) => {
|
|
234
|
+
// A line mixed into a bar chart is not a bar: its numbers would sit on the bars.
|
|
235
|
+
if (!chart.isDatasetVisible(i) || chart.getDatasetMeta(i).type !== 'bar')
|
|
236
|
+
return;
|
|
237
|
+
chart.getDatasetMeta(i).data.forEach((bar, j) => {
|
|
238
|
+
const { x, y } = bar.getProps(['x', 'y'], true);
|
|
239
|
+
ctx.textAlign = horizontal ? 'left' : 'center';
|
|
240
|
+
ctx.textBaseline = horizontal ? 'middle' : 'bottom';
|
|
241
|
+
ctx.fillText(format(dataset.data[j]), horizontal ? x + 6 : x, horizontal ? y : y - 4);
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
else if (type === 'line') {
|
|
246
|
+
chart.data.datasets.forEach((dataset, i) => {
|
|
247
|
+
const points = chart.getDatasetMeta(i).data;
|
|
248
|
+
const last = points[points.length - 1];
|
|
249
|
+
if (!chart.isDatasetVisible(i) || !last)
|
|
250
|
+
return;
|
|
251
|
+
const { x, y } = last.getProps(['x', 'y'], true);
|
|
252
|
+
ctx.fillStyle = dataset.borderColor ?? opts.color;
|
|
253
|
+
ctx.textAlign = 'right';
|
|
254
|
+
ctx.textBaseline = 'bottom';
|
|
255
|
+
ctx.fillText(format(dataset.data[dataset.data.length - 1]), x - 2, y - 8);
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
else if (type === 'doughnut') {
|
|
259
|
+
const arc = chart.getDatasetMeta(0).data[0];
|
|
260
|
+
if (!arc)
|
|
261
|
+
return ctx.restore();
|
|
262
|
+
const { x, y } = arc.getProps(['x', 'y'], true);
|
|
263
|
+
const total = (chart.data.datasets[0]?.data ?? []).reduce((sum, n) => sum + (typeof n === 'number' ? n : 0), 0);
|
|
264
|
+
ctx.textAlign = 'center';
|
|
265
|
+
ctx.textBaseline = 'middle';
|
|
266
|
+
ctx.fillStyle = opts.strong ?? LIGHT.ink;
|
|
267
|
+
ctx.font = `600 22px ${FONT_STACK}`;
|
|
268
|
+
ctx.fillText(format(total), x, y);
|
|
269
|
+
}
|
|
270
|
+
ctx.restore();
|
|
271
|
+
},
|
|
272
|
+
};
|
|
273
|
+
// Returns the config Chart.js draws: the user's config over the theme. output is true for the
|
|
274
|
+
// email and slack presets, which ask for roomier margins.
|
|
275
|
+
export function applyTheme(config, background, output = false) {
|
|
276
|
+
const options = isObject(config.options) ? config.options : {};
|
|
277
|
+
const settings = isObject(options.plugins?.chartpng) ? options.plugins.chartpng : {};
|
|
278
|
+
if (settings.theme === false)
|
|
279
|
+
return { data: config.data, options };
|
|
280
|
+
const palette = resolvePalette(settings, background);
|
|
281
|
+
const ink = inkFor(background);
|
|
282
|
+
const datasets = Array.isArray(config.data?.datasets) ? config.data.datasets : [];
|
|
283
|
+
// A legend only says something when a series has a name or there are several.
|
|
284
|
+
const named = datasets.length > 1 || datasets.some((d) => isObject(d) && typeof d.label === 'string' && d.label !== '');
|
|
285
|
+
const themed = underlay(themeOptions(config.type, options, ink, named, output, datasets), options);
|
|
286
|
+
themed.plugins = { ...themed.plugins, chartpngValues: { show: settings.values !== false, color: ink.muted, strong: ink.ink } };
|
|
287
|
+
return { data: themeDatasets(config.type, config.data, palette), options: themed };
|
|
288
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chartpng/render",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Chart.js config to PNG on the server, without a browser. The engine behind chartpng.dev.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/packages/render/index.js",
|
|
7
|
+
"types": "./dist/packages/render/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/packages/render/index.d.ts",
|
|
11
|
+
"default": "./dist/packages/render/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"bin": {
|
|
15
|
+
"chartpng-render": "./bin/chartpng-render.js"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"bin",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE",
|
|
22
|
+
"SECURITY.md",
|
|
23
|
+
"THIRD_PARTY_NOTICES.md"
|
|
24
|
+
],
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@napi-rs/canvas": "1.0.13",
|
|
27
|
+
"chart.js": "4.6.1"
|
|
28
|
+
},
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=22"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"chart",
|
|
34
|
+
"chart.js",
|
|
35
|
+
"png",
|
|
36
|
+
"image",
|
|
37
|
+
"canvas",
|
|
38
|
+
"server-side"
|
|
39
|
+
],
|
|
40
|
+
"homepage": "https://chartpng.dev",
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "git+https://github.com/chartpng/chartpng.git",
|
|
44
|
+
"directory": "packages/render"
|
|
45
|
+
},
|
|
46
|
+
"bugs": {
|
|
47
|
+
"email": "hola@chartpng.dev"
|
|
48
|
+
},
|
|
49
|
+
"author": "ChartPNG <hola@chartpng.dev> (https://chartpng.dev)",
|
|
50
|
+
"license": "MIT",
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "node build.mjs"
|
|
53
|
+
}
|
|
6
54
|
}
|