g2plot 双轴图加线图 不能实现分组柱形图双y轴 #5519
Answered
by
pearmini
18211365467
asked this question in
Q&A
-
|
Beta Was this translation helpful? Give feedback.
Answered by
pearmini
Sep 8, 2023
Replies: 5 comments
-
Beta Was this translation helpful? Give feedback.
0 replies
-
这个问题的答案: import { Chart } from '@antv/g2';
const chart = new Chart({ container: 'container' });
chart.options({
type: 'view',
data: [
{ time: '10:10', call: 4, waiting: 2, people: 2 },
{ time: '10:15', call: 2, waiting: 6, people: 3 },
{ time: '10:20', call: 13, waiting: 2, people: 5 },
{ time: '10:25', call: 9, waiting: 9, people: 1 },
{ time: '10:30', call: 5, waiting: 2, people: 3 },
{ time: '10:35', call: 8, waiting: 2, people: 1 },
{ time: '10:40', call: 13, waiting: 1, people: 2 },
],
children: [
{
type: 'interval',
encode: {
x: 'time',
y: 'waiting',
color: () => 'waiting',
series: () => 'waiting',
},
scale: { y: { nice: true } },
axis: { y: { title: null } },
},
{
type: 'interval',
encode: {
x: 'time',
y: 'people',
color: () => 'people',
series: () => 'people',
},
scale: { y: { independent: true } },
axis: { y: { position: 'right', grid: null, title: null } },
},
{
type: 'line',
encode: {
x: 'time',
y: 'call',
color: () => 'call',
},
scale: { series: { independent: true } },
},
],
});
chart.render(); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
pearmini
-
Beta Was this translation helpful? Give feedback.
0 replies
-
Beta Was this translation helpful? Give feedback.
0 replies
-
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
这个问题的答案: