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 轴Label显示异常 #4362

Closed
tangsj opened this issue Nov 25, 2022 · 5 comments
Closed

X 轴Label显示异常 #4362

tangsj opened this issue Nov 25, 2022 · 5 comments

Comments

@tangsj
Copy link

tangsj commented Nov 25, 2022

import { Chart } from '@antv/g2';

const data = [{"title":"2022-11-16","type":"实时库存金额","value":61.94},{"title":"2022-11-16","type":"报损金额","value":0},{"title":"2022-11-16","type":"退货金额","value":0},{"title":"2022-11-17","type":"实时库存金额","value":61.94},{"title":"2022-11-17","type":"报损金额","value":0},{"title":"2022-11-17","type":"退货金额","value":0},{"title":"2022-11-18","type":"实时库存金额","value":61.94},{"title":"2022-11-18","type":"报损金额","value":0},{"title":"2022-11-18","type":"退货金额","value":0},{"title":"2022-11-19","type":"实时库存金额","value":61.94},{"title":"2022-11-19","type":"报损金额","value":0},{"title":"2022-11-19","type":"退货金额","value":0},{"title":"2022-11-20","type":"实时库存金额","value":61.94},{"title":"2022-11-20","type":"报损金额","value":0},{"title":"2022-11-20","type":"退货金额","value":0},{"title":"2022-11-21","type":"实时库存金额","value":61.94},{"title":"2022-11-21","type":"报损金额","value":0},{"title":"2022-11-21","type":"退货金额","value":0},{"title":"2022-11-22","type":"实时库存金额","value":61.94},{"title":"2022-11-22","type":"报损金额","value":0},{"title":"2022-11-22","type":"退货金额","value":0},{"title":"2022-11-23","type":"实时库存金额","value":61.94},{"title":"2022-11-23","type":"报损金额","value":0},{"title":"2022-11-23","type":"退货金额","value":0},{"title":"2022-11-24","type":"实时库存金额","value":61.94},{"title":"2022-11-24","type":"报损金额","value":0},{"title":"2022-11-24","type":"退货金额","value":0}];

const chart = new Chart({
  container: 'container',
  autoFit: true,
  height: 500,
  padding: [50, 20, 50, 20],
});
chart.data(data);
chart.scale('value', {
  nice: true
});

chart.tooltip({
  shared: true,
  showMarkers: false,
  showCrosshairs: true,
});

chart.line().position('title*value').color('type').label('value');
chart.point().position('title*value').color('type');
chart.render();

显示效果如下:

image

期望Lable日期显示正常。

@ai-qing-hai
Copy link
Collaborator

chart.scale('title',{
tickCount: null,
});
这个加上看一下吧
image

@ai-qing-hai
Copy link
Collaborator

或者 chart.scale('title',{ type: 'time' })

@ai-qing-hai
Copy link
Collaborator

@visiky v3 版本 scale 中, timeCat 默认 this.tickCount = 7 , 当前代码逻辑中,也确实 被 this.tickCount 约束展示个数
image

@ai-qing-hai
Copy link
Collaborator

@tangsj 看一下上面吧

@tangsj
Copy link
Author

tangsj commented Nov 29, 2022

使用

chart.scale('title',{
tickCount: null,
});

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

均可以显示正常

@tangsj tangsj closed this as completed Nov 29, 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