Skip to content

集成 g2plot 的图表功能(Integrated g2plot chart) #5196

Answered by pearmini
zhengxs2018 asked this question in Q&A
Discussion options

You must be logged in to vote

G2 5.0 提供了直接把图表渲染进 G 的一个 group 的能力,可以参考如下:

import { Canvas, Group } from '@antv/g';
import { Renderer as CanvasRenderer } from '@antv/g-canvas';
import { Chart } from '@antv/g2';

// Create a renderer.
const renderer = new CanvasRenderer();

// Create a canvas.
const canvas = new Canvas({
  container: 'container',
  width: 600,
  height: 500,
  renderer: renderer,
});

// Create a group.
const group = new Group();
canvas.appendChild(group);

// Create a chart and mount into the group.
const chart = new Chart({ group });

chart.options({
  type: 'interval',
  theme: 'classic',
  data: {
    type: 'fetch',
    value:
      'https://gw.alipayobjects.com/os/bmw-prod/fb9db6b7-23a5-4c23-bbef-c5…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@zhengxs2018
Comment options

Comment options

You must be logged in to vote
1 reply
@zhengxs2018
Comment options

Answer selected by zhengxs2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
3 participants
Converted from issue

This discussion was converted from issue #5194 on June 15, 2023 01:45.