npm.io
0.1.2 • Published yesterday

flint-chart

Licence
MIT
Version
0.1.2
Deps
0
Size
22.8 MB
Vulns
0
Weekly
105

flint-chart

A semantic-level visualization library that compiles data + semantic types into chart specifications for Vega-Lite, ECharts, and Chart.js.

You (or an LLM) describe a chart at the semantic level: chart type, field assignments, and a semantic type per field (e.g. Revenue, Rank, CategoryCode). A deterministic compiler derives the low-level parameters (sizing, zero-baseline, number formatting, color schemes, mark templates) so charts look good and stay editable without another model call.

Pure TypeScript. No UI framework dependencies. Data in, spec out.

Install

npm install flint-chart

Quick start

import { assembleVegaLite, type ChartAssemblyInput } from 'flint-chart';

const input: ChartAssemblyInput = {
  data: {
    values: [
      { region: 'North', revenue: 120 },
      { region: 'South', revenue: 90 },
      { region: 'East', revenue: 150 },
    ],
  },
  semantic_types: { region: 'Category', revenue: 'Quantity' },
  chart_spec: {
    chartType: 'Bar Chart',
    encodings: { x: { field: 'region' }, y: { field: 'revenue' } },
  },
};

const vegaLiteSpec = assembleVegaLite(input);

The same ChartAssemblyInput compiles to any backend:

import { assembleVegaLite, assembleECharts, assembleChartjs } from 'flint-chart';

const vl = assembleVegaLite(input);   // Vega-Lite spec
const ec = assembleECharts(input);    // ECharts option
const cj = assembleChartjs(input);    // Chart.js config

Subpath exports

Import Contents
flint-chart Top-level: the three assemble* functions plus core types
flint-chart/core Semantic types, ChartAssemblyInput, shared compiler logic
flint-chart/vegalite Vega-Lite backend
flint-chart/echarts ECharts backend
flint-chart/chartjs Chart.js backend
flint-chart/test-data Sample data generators used by the gallery and tests
flint-chart/gallery Curated example specs

Both ESM (import) and CommonJS (require) builds are published, with type declarations for every entry point.

Rendering

This package produces specs, not pixels. To render those specs to PNG or SVG without a browser, use the companion flint-chart-mcp server (or pass the spec to your own Vega-Lite / ECharts / Chart.js renderer).

Documentation

License

MIT Microsoft Corporation

Keywords