Canvas 渲染器

源码
import { Chart } from '@antv/g2';

const chart = new Chart({
  container: 'container',
  autoFit: true,
});

chart.options({
  type: 'spaceFlex',
  data: {
    type: 'fetch',
    value: 'https://assets.antv.antgroup.com/g2/seattle-weather.json',
  },
  direction: 'col',
  ratio: [1, 1],
  children: [
    {
      type: 'spaceFlex',
      direction: 'row',
      ratio: [1, 1],
      children: [
        {
          type: 'interval',
          transform: [{ type: 'groupX', y: 'mean' }],
          encode: {
            x: (d) => new Date(d.date).getUTCMonth(),
            y: 'precipitation',
          },
        },
        {
          type: 'line',
          transform: [{ type: 'groupX', y: 'mean' }],
          encode: {
            x: (d) => new Date(d.date).getUTCMonth(),
            y: 'wind',
            shape: 'smooth',
          },
        },
      ],
    },
    {
      type: 'spaceFlex',
      direction: 'row',
      ratio: [1, 1],
      children: [
        {
          type: 'area',
          transform: [{ type: 'groupX', y: 'mean' }],
          encode: {
            x: (d) => new Date(d.date).getUTCMonth(),
            y: ['temp_min', 'temp_max'],
            shape: 'smooth',
          },
        },
        {
          type: 'point',
          transform: [{ type: 'groupX', y: 'mean' }],
          encode: { x: 'temp_min', y: 'temp_max', shape: 'point' },
        },
      ],
    },
  ],
});

chart.render();
全站搜索
文档与示例输入关键词开始搜索

输入关键词,查找文档、API 与示例

选择打开Esc关闭