EChartify
A non-polymorphic JSON Intermediate Representation (IR) for Apache ECharts that enables AI assistants to reliably generate and validate chart configurations.
Why EChartify?
Apache ECharts uses a highly polymorphic option object where:
- The
seriesarray changes shape based ontype(line, bar, pie, scatter, etc.) - Fields are context-sensitive with implicit defaults
- Cross-field dependencies exist (e.g., coordinate systems affect valid fields)
This polymorphism makes it difficult for AI assistants to generate correct configurations. EChartify solves this with:
| Feature | Benefit |
|---|---|
| Non-polymorphic IR | Same structure for all chart types |
| Simple JSON Schema | No oneOf, anyOf, or conditional logic |
| TypeScript-first | Zod schemas as the source of truth |
| Deterministic compiler | IR → ECharts transformation |
Architecture
┌─────────────────────────────────────────────────────────┐
│ Data Flow │
├─────────────────────────────────────────────────────────┤
│ │
│ AI / User │
│ │ │
│ ▼ │
│ ┌─────────┐ │
│ │Chart IR │ ◄── Non-polymorphic JSON │
│ └────┬────┘ │
│ │ │
│ ├──────────────────┐ │
│ ▼ ▼ │
│ ┌─────────┐ ┌───────────┐ │
│ │ Zod │ │JSON Schema│──► Go (backend) │
│ │ Schema │ │(generated)│ │
│ └────┬────┘ └───────────┘ │
│ │ │
│ ▼ │
│ ┌─────────┐ │
│ │Compiler │ │
│ └────┬────┘ │
│ │ │
│ ▼ │
│ ┌─────────┐ │
│ │ ECharts │ │
│ │ Option │ │
│ └─────────┘ │
│ │
└─────────────────────────────────────────────────────────┘
Features
- 5 Chart Types: Line, bar, pie, scatter, area
- Typed Datasets: Column metadata enables automatic type coercion
- Validation: Zod schemas provide detailed error messages
- Dual Language: TypeScript and Go implementations
- AI-Ready: Simple schema ideal for LLM code generation
Quick Links
- Getting Started - Installation and basic usage
- Schema Reference - Complete IR specification
- Examples - Chart configuration examples
- API Reference - TypeScript and Go APIs
Project Status
License
MIT