Skip to content

是否無法搭配使用 facetRect 和 coordinate('polar') #5219

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

You must be logged in to vote

正确的用法应该如下:

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

const data = [
  {
    type: '《山河圖》',
    value: 1,
    n: 64,
  },
  {
    type: '《山河圖》',
    value: 2,
    n: 37,
  },
  {
    type: '《山河圖》',
    value: 3,
    n: 29,
  },
  {
    type: '《歸途有風》',
    value: 1,
    n: 58,
  },
  {
    type: '《歸途有風》',
    value: 2,
    n: 38,
  },
  {
    type: '《歸途有風》',
    value: 3,
    n: 25,
  },
];
const chart = new Chart({
  container: 'container',
  autoFit: true,
  theme: 'classic',
});

const facetchart = chart.facetRect().data(data).encode('x', 'type');

facetchart
  .interval()
  .coordinate({ type: 'polar' }) //  这里设置 polar
  .encode('x', 'value')
  .encode('y', 'n')
  .encode('color', 'value')
  .a…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@pearmini
Comment options

@Dennishi0925
Comment options

Answer selected by pearmini
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants