Skip to content

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

@khazit

Description

@khazit

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

- OS:
- Browser:
- Framework:

Any additional comments?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugenThis issue is in EnglishpendingWe are not sure about whether this is a bug/new feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions