怎么设置坐标轴的显示范围
#6057
-
问题描述如何设置坐标轴的显示范围?比如设置折线图的显示范围为 -10 到 10 重现链接No response 重现步骤
预期行为No response 平台
屏幕截图或视频(可选)No response 补充说明(可选)No response |
Beta Was this translation helpful? Give feedback.
Answered by
pearmini
Jan 19, 2024
Replies: 1 comment
-
通过 scale.y.domain 设置: import { Chart } from '@antv/g2';
const 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 },
];
const chart = new Chart({
container: 'container',
autoFit: true,
});
chart.data(data);
chart
.interval()
.encode('x', 'time')
.encode('y', 'waiting')
.axis('y', { title: 'Waiting', titleFill: '#5B8FF9' });
chart
.line()
.encode('x', 'time')
.encode('y', 'people')
.encode('shape', 'smooth')
.style('stroke', '#fdae6b')
.style('lineWidth', 2)
.scale('y', { independent: true, domain:[-10, 10] }) // 这里
.axis('y', {
position: 'right',
grid: null,
title: 'People',
titleFill: '#fdae6b',
});
chart.render(); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
hustcc
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
通过 scale.y.domain 设置: