How antvis/g2 works
Project type and purpose
• This is an open-source, modular JavaScript/TypeScript library (G2) providing a declarative “grammar of graphics” for building rich data visualizations.
• It is not a traditional frontend/backend web app; instead it is a standalone visualization engine, supplemented by a documentation site, playground, and various build & test scripts.
File structure
• src/ – the heart of G2. Contains domain-driven subfolders:
• bundle/ – prebuilt bundles (std & lite).
• __tests__/ – comprehensive unit, integration, snapshot tests using Vitest.
• scripts/ – tooling for benchmarks, tree-shaking experiments, site generation, etc.
• playground/ – simple demo loader (index.html + index.js).
• site/ – Dumi-powered documentation & examples site.
• rollup.config.js, vite.config.ts, vitest.config.ts, tsconfig.json – build, test and type configurations.
• .github/workflows/ – CI/CD pipelines for build, test, documentation deployment, issue triaging.
README for additional insights
• Core purpose: “progressive, declarative API” for charting.
• Emphasis on extensibility (scales, transforms, marks) and pluggable rendering via G (Canvas/SVG/WebGL).
• Ecosystem: React wrappers, extensions, etc.
• CI integrates GitHub Actions to build, test, publish to npm, and deploy docs.