fix: update image.json
A simplified, LLM-friendly infographic schema library built on top of VChart.
npm | GitHub | VChart
@visactor/vinfo-graphics provides a schema-first way to describe infographic charts, and converts schema objects to VChart spec.
@visactor/vinfo-graphics
It is designed for:
Supported chart types:
pie
bar
column
area
treemap
circlePacking
toVChartSpec
validateWithZod
presetThemes
resolveTheme
# npm npm install @visactor/vinfo-graphics zod # pnpm pnpm add @visactor/vinfo-graphics zod # yarn yarn add @visactor/vinfo-graphics zod
import VChart from '@visactor/vchart'; import { toVChartSpec } from '@visactor/vinfo-graphics'; const schema = { chartType: 'bar', title: 'Monthly Sales', data: [ { month: 'Jan', sales: 120 }, { month: 'Feb', sales: 160 }, { month: 'Mar', sales: 180 }, ], categoryField: 'month', valueField: 'sales', } as const; const spec = toVChartSpec(schema); const chart = new VChart(spec, { dom: 'chart' }); chart.renderSync();
import { validate } from '@visactor/vinfo-graphics'; const result = validate({ chartType: 'pie', data: [{ name: 'A', value: 30 }], categoryField: 'name', valueField: 'value', }); console.log(result.valid, result.errors);
import { validateWithZod } from '@visactor/vinfo-graphics'; // Auto-select schema by data.chartType const result = validateWithZod({ chartType: 'column', data: [{ category: 'Q1', value: 120 }], categoryField: 'category', valueField: 'value', }); console.log(result.success, result.errors);
You can also pass an explicit schema:
import { validateWithZod } from '@visactor/vinfo-graphics'; import { pieChartSchema } from '@visactor/vinfo-graphics/schemas'; const result = validateWithZod(pieChartSchema, { chartType: 'pie', data: [{ name: 'A', value: 30 }], categoryField: 'name', valueField: 'value', });
Main exports from @visactor/vinfo-graphics:
toVChartSpec(schema)
validate(schema)
getDefaults(chartType)
validateWithZod(data)
validateWithZod(schema, data)
isDarkTheme
Schemas export path:
@visactor/vinfo-graphics/schemas
UMD entry:
@visactor/vinfo-graphics/umd
After build:
esm/**
cjs/**
dist/**/*.d.ts
dist/index.umd.js
# install npm install # type check npm run typecheck # test npm run test # build all outputs (esm/cjs/types/umd) npm run build
MIT
版权所有:中国计算机学会技术支持:开源发展技术委员会 京ICP备13000930号-9 京公网安备 11010802032778号
@visactor/vinfo-graphics
A simplified, LLM-friendly infographic schema library built on top of VChart.
npm | GitHub | VChart
Introduction
@visactor/vinfo-graphicsprovides a schema-first way to describe infographic charts, and converts schema objects to VChart spec.It is designed for:
Supported chart types:
piebarcolumnareatreemapcirclePackingFeatures
toVChartSpecvalidateWithZodpresetThemes,resolveTheme)Installation
Quick Start
Validation
1) Validate by converter rules
2) Validate by Zod schema
You can also pass an explicit schema:
API
Main exports from
@visactor/vinfo-graphics:toVChartSpec(schema)validate(schema)getDefaults(chartType)validateWithZod(data)/validateWithZod(schema, data)presetThemesresolveThemeisDarkThemeSchemas export path:
@visactor/vinfo-graphics/schemasUMD entry:
@visactor/vinfo-graphics/umdBuild Output
After build:
esm/**cjs/**dist/**/*.d.tsdist/index.umd.jsDevelopment
Related Links
License
MIT