// 冒烟:v2.9.2 的 charts.js 在 Node 里能否出 SVG(用最小夹具) import { readFileSync } from 'node:fs' import { fileURLToPath } from 'node:url' import { dirname, resolve } from 'node:path' const HERE = dirname(fileURLToPath(import.meta.url)) const src = readFileSync(resolve(HERE, '../src/lib/legacy/charts.js'), 'utf8') const sandbox = { window: {} } const fn = new Function('window', 'document', 'navigator', src + '\nreturn window.__charts;') const factory = fn(sandbox.window, {}, {}) const CH = factory({ t: (k) => k, fmt: (v) => String(v), esc: (s) => String(s), dv: (v) => String(v), EN: false, displayText: (x) => String(x == null ? '' : x), verb: () => {} }) const svg1 = CH.rateChart({ months: ['m1', 'm2'], vals: [1, 2], cov: [1, 1], per_day: [0.5, 0.8] }) const svg2 = CH.quadChart([{ n: 3, med: 700, nt: 3, 部件: 'x' }]) console.log('rateChart:', /^