You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by "khazit (via GitHub)" <gi...@apache.org> on 2026/01/15 15:37:18 UTC
[I] [Bug] `barWidth` on time-based bar series unexpectedly expands xAxis min/max [echarts]
khazit opened a new issue, #21478:
URL: https://github.com/apache/echarts/issues/21478
### 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_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [I] [Bug] `barWidth` on time-based bar series unexpectedly expands xAxis min/max [echarts]
Posted by "helgasoft (via GitHub)" <gi...@apache.org>.
helgasoft commented on issue #21478:
URL: https://github.com/apache/echarts/issues/21478#issuecomment-3757511301
<img align="left" width="100" alt="Image" src="https://github.com/user-attachments/assets/ef9fa67e-39d5-4054-bfeb-5b3ec9c822e5" />
This is by design. ECharts is auto-sizing the time axis depending on bar width. <br>
Change series type to 'scatter' to see the difference - the two points are placed at either end of the axis. The reason is that scatter points are "immaterial" and have no width to consider.<br>
If you need more control over the axis, use pixel values like <code>barWidth:11</code>.
<br clear="left"/>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [I] [Bug] `barWidth` on time-based bar series unexpectedly expands xAxis min/max [echarts]
Posted by "khazit (via GitHub)" <gi...@apache.org>.
khazit commented on issue #21478:
URL: https://github.com/apache/echarts/issues/21478#issuecomment-3760670746
I'm really struggling to understand how this is supposed to be a feature. Did you even test the sandbox link?
Setting `barWidth: "90%"` expands the xAxis by multiple days That’s not auto-sizing. Why would **decreasing** the bar width **increase** the x axis?
Also, why does this only happen with two points, but not with three?
```
option = {
xAxis: {
type: 'time',
},
yAxis: {
type: 'value'
},
series: [
{
data: [
[1768428600000, 1],
[1768466400000, 1],
[1768506400000, 1],
],
type: 'bar',
barWidth: "90%",
}
]
};
```
If this were an intentional sizing rule, it should behave consistently regardless of point count.
I understand that bars have width and that scatter points don’t. That still doesn’t explain why a percentage-based bar width should massively distort a time axis to this extent, and only under very specific conditions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [I] [Bug] `barWidth` on time-based bar series unexpectedly expands xAxis min/max [echarts]
Posted by "helgasoft (via GitHub)" <gi...@apache.org>.
helgasoft commented on issue #21478:
URL: https://github.com/apache/echarts/issues/21478#issuecomment-3761025916
To help clarify a bit, API for [barWidth](https://echarts.apache.org/en/option.html#series-bar.barWidth) says:
_"...percent value like '60%'. The percent is based on the calculated **category** width."_
This means that _barWidth %_ should be used with the category axis rather than the time axis.
I agree about the inconsistency in auto-sizing behavior. Maybe the API should be updated to explain it better.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org