npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@opendata-ai/openchart-engine

v2.8.1

Published

Headless compiler for openchart: spec validation, data compilation, scales, and layout

Readme

@opendata-ai/openchart-engine

Headless compiler for OpenChart. Takes a spec (plain JSON), validates it, and produces a fully resolved layout with computed positions, scales, marks, and accessibility metadata. No DOM dependency.

Install

npm install @opendata-ai/openchart-engine

You typically don't install this directly. The framework packages (openchart-react, openchart-vue, openchart-svelte) and the vanilla adapter include it as a dependency.

Core API

compile()

The main entry point. Accepts any VizSpec and returns the compiled layout:

import { compile } from '@opendata-ai/openchart-engine';

const result = compile(spec, {
  width: 600,
  height: 400,
  darkMode: false,
});
// result is a ChartLayout, TableLayout, or GraphCompilation

compileChart()

Compiles a ChartSpec into a ChartLayout with positioned marks, axes, gridlines, legends, and annotations:

import { compileChart } from '@opendata-ai/openchart-engine';

const layout = compileChart(chartSpec, { width: 600, height: 400 });
// layout.marks: positioned line paths, bar rects, arc segments, etc.
// layout.axes: tick positions, labels, format strings
// layout.legend: entries, position, dimensions
// layout.annotations: pixel-positioned annotation elements
// layout.theme: fully resolved theme with all defaults filled

compileTable()

Compiles a TableSpec into a TableLayout with resolved columns, formatted cells, and visual enhancements:

import { compileTable } from '@opendata-ai/openchart-engine';

const layout = compileTable(tableSpec, { darkMode: false });

compileGraph()

Compiles a GraphSpec into a GraphCompilation with resolved node/edge visuals and simulation config. Note: the engine doesn't compute node positions. That happens at runtime via a force simulation in the vanilla adapter.

import { compileGraph } from '@opendata-ai/openchart-engine';

const compilation = compileGraph(graphSpec, { width: 600, height: 400 });
// compilation.nodes: visual properties (size, color, label) resolved
// compilation.edges: visual properties (width, color) resolved
// compilation.simulationConfig: force parameters for the layout engine

validateSpec()

Runtime validation of any spec. Returns structured errors with paths and suggestions:

import { validateSpec } from '@opendata-ai/openchart-engine';

const result = validateSpec(spec);
if (!result.valid) {
  for (const error of result.errors) {
    console.log(`${error.path}: ${error.message}`);
    console.log(`  Suggestion: ${error.suggestion}`);
  }
}

normalizeSpec()

Fills in defaults and resolves shorthand without validation. Useful when you know the spec is valid and want the normalized form:

import { normalizeSpec } from '@opendata-ai/openchart-engine';

const normalized = normalizeSpec(spec);
// All optional fields resolved to their defaults

Chart renderer registry

Chart types are registered via a plugin pattern. The engine ships with all 8 types pre-registered (line, area, bar, column, pie, donut, dot, scatter). For advanced use, you can register custom renderers:

import { registerChartRenderer, getChartRenderer, clearRenderers } from '@opendata-ai/openchart-engine';

registerChartRenderer('custom', myCustomRenderer);

Re-exports

For convenience, this package re-exports all types from @opendata-ai/openchart-core, so you can import types from either package.

Related docs