G2
📊 The concise and progressive visualization grammar.
G2 is a TypeScript charting library from Ant Financial that builds any statistical chart by composing data field mappings and visual properties, rather than selecting from a fixed list of named chart types.
G2 is a TypeScript library for building interactive data charts in the browser, created and maintained by Ant Financial's data visualization team (AntV). It is built around the concept of a "grammar of graphics," which is a way of describing charts not as named types (bar chart, pie chart) but as combinations of data mappings and visual properties. This approach means the same library can produce almost any kind of statistical chart by composing its building blocks differently.
To use G2, you provide data, then write a short declaration that maps your data fields to visual positions and shapes. The library handles drawing the result on screen using either Canvas or SVG, and you can switch between the two rendering modes depending on what your project needs. Charts built with G2 support interactive behaviors such as tooltips, filtering, and data exploration out of the box.
The README is written primarily in Chinese and includes a code example showing how to render a bar chart: create a Chart object, load data into it, define that the x-axis maps to a category field and the y-axis to a numeric field, then call render. The example is brief and the full documentation lives on the project's external website.
For developers who want standard chart types without writing grammar-level code, the project also maintains G2Plot, a higher-level library built on top of G2 that provides pre-configured chart components you configure through a plain settings object.
G2 is part of the AntV family of open-source visualization tools and is used widely in enterprise applications developed within the Alibaba and Ant Financial ecosystem.
Where it fits
- Render an interactive bar, line, or scatter chart in the browser by mapping data fields to visual axes and shapes.
- Build custom statistical charts not available as standard types by composing G2's visual grammar primitives.
- Add interactive tooltips and click-based filtering to a data dashboard.