设置domainMin后显示超过下界
#5460
-
预期应该是不超过X轴 请问这是正常吗,或是使用错误? 示例代码: /**
* A recreation of this demo: https://observablehq.com/@d3/bar-chart
*/
import { Chart } from '@antv/g2';
const chart = new Chart({
container: 'container',
theme: 'classic',
autoFit: true,
});
chart
.interval()
.data({
type: 'fetch',
value:
'https://gw.alipayobjects.com/os/bmw-prod/fb9db6b7-23a5-4c23-bbef-c54a55fee580.csv',
})
.encode('x', 'letter')
.encode('y', 'frequency')
.axis('y', { labelFormatter: '.0%' })
.scale("y", {
domainMin: 0.1
});
chart.render(); |
Beta Was this translation helpful? Give feedback.
Answered by
pearmini
Aug 24, 2023
Replies: 2 comments
-
柱形图其实 y 是有两个,一个是底部,一个是顶部,只是默认底部为 0 而已。如果期望设置底部为 0.1 开始,那可以这样写。 .encode('y', [0.1, 'frequency'])
.scale('y', { domainMin: 0.1 }) |
Beta Was this translation helpful? Give feedback.
0 replies
-
这个是合理的,因为条的下边界的数据是 0。除了上诉方法之外,还可以: const chart = new Chart({
clip: true // 隐藏超出绘制区域的地方
}) 或者 interval().scale('y', {
domainMin: 0.1
clamp: true
}); |
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
这个是合理的,因为条的下边界的数据是 0。除了上诉方法之外,还可以:
或者