@chartguard/config-highcharts
v0.1.1
Published
Highcharts configuration validator (partial, explicit coverage)
Readme
@chartguard/config-highcharts
Highcharts configuration validator. Partial coverage: a clean result means no confirmed error was found, not that the configuration is complete or correct (read status).
Status: pre-release (0.x). Coverage is partial, and the API and settings may still change between minor versions.
npm install @chartguard/config-highchartsThis package does not ship a schema derived from Highcharts. The Highcharts license does not clear redistributing option metadata derived from its declarations, so the full schema is generated on your machine from your own installed highcharts, under your own license.
Two ways to validate
import { readFileSync } from "node:fs";
import { createValidator, validate } from "@chartguard/config-highcharts";
// 1. A small hand-written subset, always available.
validate(config);
// 2. The full option set of your installed version, from a locally generated schema artifact.
const validateFull = createValidator(JSON.parse(readFileSync(artifactPath, "utf8")));
validateFull(config, { libraryVersion: "13.1.1" });createValidator throws for a malformed artifact or one generated for another library.
A series type added by a plugin is an unknown variant (a warning); describe it to have it checked: createValidator(artifact, { extensions: [{ id: "flame3d", variants: { "highcharts.series": { flame3d: s.object({ depth: s.number() }) } } }] }) (s from @chartguard/config-core). A variant may extend a built-in series and add its own options ({ flame3d: { extends: "line", schema: s.object({ depth: s.number() }) } }); chart.type: "flame3d" then selects it for series without type. A built-in type cannot be replaced; a refused extension throws ExtensionError. A series without type is checked as the type the runtime gives it: chart.type, else line (the runtime's default); when chart.type cannot be read without running code, or names no known or described series type, the series is inconclusive (CFG_AMBIGUOUS), never checked against a guessed type.
Generate the artifact from your installed highcharts with npx chartguard schema build --library highcharts (or buildLocalSchema from @chartguard/schema-generator); it is written to node_modules/.cache/chartguard/highcharts-<version>.json, which chartguard validate --library highcharts reads. Inside the ChartGuard repository, npm run build writes it there too.
