antvis/G2


The issue has been closed
数据都是负数的时候对比例尺设置最大值失效 #4412
xiekailian posted onGitHub
代码如下:
import { Chart } from '@antv/g2';
const data = [
{ type: '未知', value: -10, percent: 0.02 },
{ type: '17 岁以下', value: -20, percent: 0.02 },
{ type: '18-24 岁', value: -30, percent: 0.2 },
{ type: '25-29 岁', value: -40, percent: 0.24 },
];
const chart = new Chart({
container: 'container',
autoFit: true,
height: 500,
padding: [50, 20, 50, 20],
});
chart.data(data);
chart.scale('value', {
alias: '销售额(万)',
});
chart.axis('type', {
tickLine: {
alignTick: false,
},
});
chart.tooltip({
showMarkers: false,
});
chart.interval().position('type*value');
chart.interaction('element-active');
chart.scale('value', {
max: -50
});
chart.render();
设置比例尺的最大值为 -50,预期情况是,什么都不显示,因为所有值都比 -50 大,就像这样: <img width="598" alt="image" src="https://user-images.githubusercontent.com/18750815/205858638-48b66988-af94-420b-8543-c28fa621adea.png"> 然而官网复现出来,是这样: <img width="832" alt="image" src="https://user-images.githubusercontent.com/18750815/205858886-4c7a9dd8-c966-43fd-b31a-1a67622cd3ef.png"> 看起来只隐藏了第一个数据,其他的没反应。