Skip to content
项目

关于

💥 用于可视化的灵活渲染引擎。

设计与媒体

这些数字如何统计

可以做什么

  • canvas-renderer Rendering 2D graphics based on Canvas2D.
  • svg-renderer Rendering 2D graphics based on SVG.
  • g-plugin-device-renderer Rendering 2D graphics based on GPUDevice.
  • html-renderer Rendering DOM with HTML.

实测星标增长

24小时
0
7天
-2
15天
-1
1个月
0

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README-zh_CN.md

原文

English | 简体中文

G

CI Coverage Status semantic-release: angular

TypeScript License

npm package npm downloads Percentage of issues still open PRs Welcome Ask DeepWiki

一款高效易用的可视化渲染引擎。

D3 force directed graph D3 barchart D3 sketchy barchart Yoga plugin Box2D physics engine plugin Rough.js plugin Canvaskit plugin Yoga plugin Canvaskit plugin 3D force directed graph

✨ 特性

📦 安装

# 安装核心包
$ npm install @antv/g --save
# Canvas 渲染器
$ npm install @antv/g-canvas --save
# SVG 渲染器
$ npm install @antv/g-svg --save
# WebGL 渲染器
$ npm install @antv/g-webgl --save

🔨 使用

<div id="container"></div>
import { Circle, Canvas, CanvasEvent } from '@antv/g';
import { Renderer as CanvasRenderer } from '@antv/g-canvas';
// or
// import { Renderer as WebGLRenderer } from '@antv/g-webgl';
// import { Renderer as SVGRenderer } from '@antv/g-svg';

// 创建画布
const canvas = new Canvas({
    container: 'container',
    width: 500,
    height: 500,
    renderer: new CanvasRenderer(), // 选择一个渲染器
});

// 创建一个圆
const circle = new Circle({
    style: {
        cx: 100,
        cy: 100,
        r: 50,
        fill: 'red',
        stroke: 'blue',
        lineWidth: 5,
    },
});

canvas.addEventListener(CanvasEvent.READY, function () {
    // 加入画布
    canvas.appendChild(circle);

    // 监听 `click` 事件
    circle.addEventListener('click', function () {
        this.style.fill = 'green';
    });
});

⌨️ 开发

启动并预览示例:

git clone [email protected]:antvis/g.git
cd g
pnpm install
pnpm build
pnpm dev

API Spec

在项目根目录下启动开发服务器,例如 http-server:

http-server -p 9090

访问 localhost:9090/spec/api.html 即可预览 API Spec。

运行测试用例

构建并运行测试用例:

pnpm build
pnpm test

启动开发示例

构建并启动 vite 示例:

pnpm build
pnpm dev

受以下项目启发

探索相关项目

加载中…