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

以日期字符串作为横坐标时,部分横坐标显示不出 #4069

Closed
1 task done
xiekailian opened this issue Aug 5, 2022 · 1 comment
Closed
1 task done

Comments

@xiekailian
Copy link

xiekailian commented Aug 5, 2022

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

https://github.com/antvis/G2

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 这三个横坐标没有显示出来,问题截图如下:
image

Environment Info
g2 4.2.5
System -
Browser Chrome
@hustcc
Copy link
Member

hustcc commented Sep 9, 2022

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

手动指定一下类型。

@hustcc hustcc closed this as completed Sep 9, 2022
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