Skip to content

Latest commit

 

History

History
162 lines (130 loc) · 8.06 KB

README-zh_CN.md

File metadata and controls

162 lines (130 loc) · 8.06 KB

English | 简体中文

G

CI Coverage Status semantic-release: angular

TypeScript License

npm package npm downloads Percentage of issues still open PRs Welcome

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

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 git@github.com: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

受以下项目启发