apache / apache/echarts

[Bug] Bar positions on timeline

Open
#21,269 7 comments 0 reactions 0 assignees View on GitHub
bug en pending
Dominant language
TypeScript
Stars
67.3k
Forks
19.8k
Avg merge
11d 14h
Merged PRs (30d)
8

Description

### Version

5.5.1

### Link to Minimal Reproduction

https://codesandbox.io/p/sandbox/apache-echarts-demo-forked-4vg9mg

### Steps to Reproduce

just open https://codesandbox.io/p/sandbox/apache-echarts-demo-forked-4vg9mg

The bug is reproduced with the xAxis type = time and add any bars.

### Current Behavior

Bars offset totally incorrect!

![Image](https://github.com/user-attachments/assets/a2e76017-dc14-4d74-bf8b-40bc1e0c9729)

### Expected Behavior

The bars should be positioned exactly in their positions.

### Environment

```markdown
- OS: Ubuntu 20.04.6
- Browser: Chrome 139.0.7258.127
- Framework: Vue@2
```

### Any additional comments?

[src/layout/barGrid.ts](https://github.com/apache/echarts/blob/513918064ac2a0866433d434dc969220f12b9c1a/src/layout/barGrid.ts#L405-L414)

```
let offset = -widthSum / 2;
each(stacks, function (column, stackId) {
result[coordSysName][stackId] = result[coordSysName][stackId] || {
bandWidth: bandWidth,
offset: offset,
width: column.width
} as BarWidthAndOffset[string][string];

offset += column.width * (1 + barGapPercent);
});
```

if change it to
```
each(stacks, function (column, stackId) {
result[coordSysName][stackId] = result[coordSysName][stackId] || {
bandWidth: bandWidth,
offset: -column.width / 2,
width: column.width
} as BarWidthAndOffset[string][string];
});
```
Everything is working as it should, but it seems that offset is needed for something :)). I have not found a single case where this would be necessary, everything seems to be working well.

If you tell me where this offset curve is needed, I will try to fix it and send you an pull request.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.