Skip to content

一个图可以在横向维度上分组吗? #5059

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

You must be logged in to vote

目前可以通过嵌套分面实现类似的效果:

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

const chart = new Chart({
  container: 'container',
  theme: 'classic',
  width: 800,
  height: 400,
  paddingLeft: 60,
});

chart.options({
  type: 'facetRect',
  data: [
    { name: 'a', sex: 'male', country: 'A', value: 10 },
    { name: 'a', sex: 'male', country: 'B', value: 6 },
    { name: 'b', sex: 'male', country: 'A', value: 3 },
    { name: 'b', sex: 'male', country: 'B', value: 2 },
    { name: 'a', sex: 'female', country: 'A', value: 9 },
    { name: 'a', sex: 'female', country: 'B', value: 8 },
    { name: 'b', sex: 'female', country: 'A', value: 7 },
    { name: 'b', sex: 'female', country: 'B', value: 3 },
  ],
  encode: {

Replies: 1 comment 3 replies

Comment options

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

@ChristmasFox
Comment options

@hustcc
Comment options

Answer selected by hustcc
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 #5058 on May 19, 2023 03:04.