Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

设置domainMin后显示超过下界 #5454

Closed
KuduroJS opened this issue Aug 23, 2023 · 2 comments
Closed

设置domainMin后显示超过下界 #5454

KuduroJS opened this issue Aug 23, 2023 · 2 comments

Comments

@KuduroJS
Copy link

image

预期应该是不超过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();
@hustcc
Copy link
Member

hustcc commented Aug 24, 2023

柱形图其实 y 是有两个,一个是底部,一个是顶部,只是默认底部为 0 而已。如果期望设置底部为 0.1 开始,那可以这样写。

  .encode('y', [0.1, 'frequency'])
  .scale('y', { domainMin: 0.1 })

@pearmini
Copy link
Member

这个是合理的,因为条的下边界的数据是 0。除了上诉方法之外,还可以:

const chart = new Chart({
  clip: true // 隐藏超出绘制区域的地方
})

或者

interval().scale('y', { 
  domainMin: 0.1 
  clamp: true
});

@antvis antvis locked and limited conversation to collaborators Aug 24, 2023
@pearmini pearmini converted this issue into discussion #5460 Aug 24, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants