一个图可以在横向维度上分组吗? #5059
Answered
by
pearmini
ChristmasFox
asked this question in
Q&A
一个图可以在横向维度上分组吗?
#5059
-
Beta Was this translation helpful? Give feedback.
Answered by
pearmini
May 19, 2023
Replies: 1 comment 3 replies
-
目前可以通过嵌套分面实现类似的效果: 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: { x: 'country' },
axis: { x: { position: 'bottom', tick: false, title: false } },
paddingBottom: 30,
children: [
{
type: 'facetRect',
encode: { x: 'sex' },
axis: { x: { position: 'bottom', title: false, tick: false } },
paddingBottom: 20,
children: [
{
type: 'interval',
frame: false,
paddingBottom: 20,
encode: { x: 'name', y: 'value', color: 'country' },
axis: { x: { title: false } },
},
],
},
],
});
chart.render(); |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
hustcc
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
目前可以通过嵌套分面实现类似的效果: