G2
G2 copied to clipboard
以日期字符串作为横坐标时,部分横坐标显示不出
- [ ] I have searched the issues of this repository and believe that this is not a duplicate.
Reproduction link
Steps to reproduce
直接使用如下代码,在 G2 官网可复现这个问题:
import { Chart } from '@antv/g2';
const data = [
{
name: '19',
category: '2022/7/25',
value: 40,
},
{
name: '19',
category: '2022/7/26',
value: 18,
},
{
name: '19',
category: '2022/7/27',
value: 10,
},
{
name: '19',
category: '2022/7/28',
value: 2,
},
{
name: '19',
category: '2022/7/29',
value: 2,
},
{
name: '19',
category: '2022/7/30',
value: 3,
},
{
name: '19',
category: '2022/7/31',
value: 6,
},
{
name: '19',
category: '2022/8/1',
value: 1,
},
{
name: '19',
category: '2022/8/2',
value: 0,
},
{
name: '19',
category: '2022/8/3',
value: 1,
},
];
const chart = new Chart({
container: 'container',
autoFit: true,
height: 500,
});
chart.data(data);
chart.scale({
year: {
range: [0, 1],
},
value: {
min: 0,
nice: true,
},
});
chart.tooltip({
showCrosshairs: true, // 展示 Tooltip 辅助线
shared: true,
});
chart.line().position('category*value').label('value');
chart.point().position('category*value');
chart.render();
其中 2022/7/30,2022/8/1,2022/8/2 这三个横坐标没有显示出来,问题截图如下:

| Environment | Info |
|---|---|
| g2 | 4.2.5 |
| System | - |
| Browser | Chrome |
chart.scale({
category: {
type: 'cat',
},
});
手动指定一下类型。