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

多条折线图x轴第7个点label消失的问题 #4879

Closed
q444937865 opened this issue Apr 8, 2023 · 3 comments
Closed

多条折线图x轴第7个点label消失的问题 #4879

q444937865 opened this issue Apr 8, 2023 · 3 comments
Assignees

Comments

@q444937865
Copy link

q444937865 commented Apr 8, 2023

官方示例中 https://antv-g2.gitee.io/zh/examples/line/basic#curved
将数据中的month改成日期,第7个label消失了,如下
image
自己本地同样可以复现,antv版本:4.2.8

@hustcc
Copy link
Member

hustcc commented Apr 23, 2023

@q444937865 代码发出来一下,我们调试一下看看看。可能的原因是开启了 axis label 自动省略,所以第 7 个和第 8 个标签重叠,所以自动隐藏了第 7 个。

@hustcc hustcc self-assigned this Apr 23, 2023
@q444937865
Copy link
Author

@hustcc 直接编辑官方示例代码中的month字段即可
https://antv-g2.gitee.io/zh/examples/line/basic#curved
数据如下:
const data = [
{ month: '2023-04-01', city: 'Tokyo', temperature: 7 },
{ month: '2023-04-01', city: 'London', temperature: 3.9 },
{ month: '2023-04-02', city: 'Tokyo', temperature: 6.9 },
{ month: '2023-04-02', city: 'London', temperature: 4.2 },
{ month: '2023-04-03', city: 'Tokyo', temperature: 9.5 },
{ month: '2023-04-03', city: 'London', temperature: 5.7 },
{ month: '2023-04-04', city: 'Tokyo', temperature: 14.5 },
{ month: '2023-04-04', city: 'London', temperature: 8.5 },
{ month: '2023-04-05', city: 'Tokyo', temperature: 18.4 },
{ month: '2023-04-05', city: 'London', temperature: 11.9 },
{ month: '2023-04-06', city: 'Tokyo', temperature: 21.5 },
{ month: '2023-04-06', city: 'London', temperature: 15.2 },
{ month: '2023-04-07', city: 'Tokyo', temperature: 25.2 },
{ month: '2023-04-07', city: 'London', temperature: 17 },
{ month: '2023-04-08', city: 'Tokyo', temperature: 26.5 },
{ month: '2023-04-08', city: 'London', temperature: 16.6 },
];
应该不是标签重叠的问题,将面板拉宽后,这么宽明显是放的下
image

@hustcc
Copy link
Member

hustcc commented Apr 25, 2023

设置一下代码:

chart.scale('month', { type: 'cat' });

原因是,G2 默认推断出数据为日期类型,所以在 04-06 和 04-08 之间补充了 04-07 这个间距。

@hustcc hustcc closed this as completed Apr 25, 2023
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