Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

数据都是负数的时候对比例尺设置最大值失效 #4412

Closed
xiekailian opened this issue Dec 6, 2022 · 2 comments
Closed

数据都是负数的时候对比例尺设置最大值失效 #4412

xiekailian opened this issue Dec 6, 2022 · 2 comments

Comments

@xiekailian
Copy link

代码如下:

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 大,就像这样:
image
然而官网复现出来,是这样:
image
看起来只隐藏了第一个数据,其他的没反应。

@hustcc
Copy link
Member

hustcc commented Dec 6, 2022

max min 都会和具体的数据进行比较之后再做处理。如果强制按照用户设置的来处理,那就用这个:

chart.scale('value', {
  maxLimit: -50, // 👈🏻
  // minLimit: 10,
});

@hustcc hustcc closed this as completed Dec 6, 2022
@xiekailian
Copy link
Author

感谢,确实有效

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants