antvis/G2

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

q444937865 posted onGitHub

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


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

posted by hustcc about 2 years ago

@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

posted by q444937865 about 2 years ago

设置一下代码:

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

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

posted by hustcc almost 2 years ago

Fund this Issue

$0.00
Funded

Pull requests