antvis / antvis/G2

[Bug]: Interval 图表使用 Date 类型作为 x 轴的时候,并没有按照时间间隔进行自动分隔

Open
#7,219 3 comments 0 reactions 0 assignees View on GitHub
bug 🐛 P1
Dominant language
TypeScript
Stars
12.6k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

### Describe the bug / 问题描述

Image
图片上面图表的是散点图,x是按时间维度进行排列的,可以自动进行时间跨度的展示。
但是下面的图表是柱状图,x轴处理为固定的跨度进行展示,当使用 scale: {x: {type: 'time'}} 的时候还会报错:scale.getBandWidth is not a function

```javascript

chart.options({
type: 'interval',
encode: {
x: (d) => new Date(d.rptdate),
y: 'value',
color: 'engloc',
},
});

```

### Reproduction link / 复现链接

_No response_

### Steps to Reproduce the Bug or Issue / 重现步骤

_No response_

### Version / 版本

🆕 5.x

### OS / 操作系统

- [x] macOS
- [ ] Windows
- [ ] Linux
- [ ] Others / 其他

### Browser / 浏览器

- [x] Chrome
- [ ] Edge
- [ ] Firefox
- [ ] Safari (Limited support / 有限支持)
- [ ] IE (Nonsupport / 不支持)
- [ ] Others / 其他

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with the shown chart.options configuration, using a Date-valued x encoding and an interval chart. Inspect how interval charts handle time x scales and the getBandWidth call; done means time intervals are automatically spaced and the time-scale configuration no longer throws an error.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.