apache / apache/echarts

[Bug] `barWidth` on time-based bar series unexpectedly expands xAxis min/max

Open
#21,478 3 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.6.0

### Link to Minimal Reproduction

https://echarts.apache.org/examples/en/editor.html?c=bar-simple&code=yy8oyczPU7BVqOZSUKhwrMgstgIzFRRKKgtSrRTUSzJzU9V1gCK1IKISi4qyxJzSVHWYiuLUosxUoJJosBKIQgWFlMSSRJgYCEQbmptZmBhZmBmAgI6CYSxIL7KcmZkJhhycAbU5KbEI7DQQALLDM1NKMqwUlCwNVJUgwrVAMpar1hoA&enc=deflate

### Steps to Reproduce

1. Create a bar chart using Apache ECharts with a time-based xAxis.
2. Use two data points that are only a few hours apart.
3. Render the chart without barWidth and observe the xAxis padding (minimal, a few hours).
4. Add barWidth: "90%" to the bar series.
5. Re-render the chart and observe that the xAxis min/max expand by multiple days.

```
option = {
xAxis: {
type: 'time',
},
yAxis: {
type: 'value'
},
series: [
{
type: 'bar',
barWidth: '90%',
data: [
[1768428600000, 1],
[1768466400000, 1],
],
}
]
};
```

### Current Behavior

When barWidth is explicitly set on a bar series using a time xAxis, ECharts significantly expands the computed xAxis range (min/max), resulting in several days of padding before and after the actual data points.

This does not happen when barWidth is omitted.

### Expected Behavior

Setting barWidth should only affect the visual width of bars and must not influence the xAxis min/max calculation.

The xAxis range and padding should remain consistent with the default behavior when barWidth is not specified.

### Environment

```markdown
- OS:
- Browser:
- Framework:
```

### Any additional comments?

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the linked Apache ECharts minimal reproduction and trace the bar series with a time-based xAxis, comparing behavior with and without barWidth: "90%". The work is done when barWidth changes only the visual bar width and the xAxis min/max padding remains consistent with the default behavior.

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
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.