@mk7s/holochart-core
v0.1.0-alpha.0
Published
Figure model, attribute schema system, validation, defaults, and update planning.
Maintainers
Readme
@mk7s/holochart-core
The figure model of Holochart: the attribute schema system, validation, defaults, templates, named colors, scales and update planning. Pure and renderer-free (it never imports three.js). Part of Holochart, declarative GPU charts on three.js.
Alpha. Released as
0.1.0-alphaon the npmalphatag; APIs can change between 0.x releases. Most apps should install the full bundle,@mk7s/holochart, which includes this package.
Install
pnpm add @mk7s/holochart-core@alphaNo peer dependencies. ESM-only; Node 22 and newer can also require() it.
What it exports
- Schema and validation:
attr,layoutSchema,configSchema,plotSchema,validate,ValidationError,HolochartError - Defaults and templates:
createRegistry,supplyDefaults,composeTemplates,resolveTemplate, and the built-inholochartTemplate,plotlyClassicTemplate,noneTemplate - Subplots:
makeSubplots - Colors:
colors,getColorscale,getColorway,registerColorscale,registerBuiltinColors(opts a partial bundle in to every named palette and colorscale) - Updates and data:
planUpdate,planRestyle,planRelayout,diffFigures,parseDate(experimental),encodeFigure/decodeFigure
attr, the schema objects and createRegistry are experimental until the plugin API
stabilises. The package also exports helpers for the other Holochart packages (scales, coercion,
rich text), tagged @internal: they are not API.
Usage
import { makeSubplots, registerBuiltinColors } from '@mk7s/holochart-core';
registerBuiltinColors(); // makes names like 'tempo' or 'Safe' resolvable in a partial bundle
const sp = makeSubplots({ rows: 1, cols: 2, subplotTitles: ['Sales', 'Costs'] });
const figure = {
data: [sp.place({ type: 'bar', x: ['a', 'b'], y: [2, 3] }, 1, 1)],
layout: { ...sp.layout },
};Docs
License
MIT (see LICENSE). The named palettes and colorscales include data from plotly.py, ColorBrewer (Apache-2.0), CARTOColors (CC BY 3.0), cmocean and matplotlib; their licenses are listed in THIRD_PARTY_NOTICES.md.
