[Bug] Inverse axis collapses the grid with outerBoundsContain when a tick is near the axis edge

Đang mở Phù hợp với người mới
#21,839 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

@xh123637 đang làm issue này rồi.

Từ ngày 14/11/2026.

  • #21842 của @xh123637 — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
data-visualization

Hướng nghiên cứu

Bắt đầu tại src/coord/cartesian/Grid.ts, ở layOutGridByOuterBounds, và theo dõi cách vị trí nhãn vạch chia ảnh hưởng đến ranh giới của lưới. Dùng bản tái hiện được liên kết để so sánh các trường hợp trục đảo ngược và không đảo ngược; issue được hoàn tất khi cả hai tạo ra cùng chiều cao lưới mà không bị thu gọn.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

en pending
Version

6.1.0

Link to Minimal Reproduction

https://echarts.apache.org/examples/en/editor.html?code=PTAEBUAsFNQJwJYHNIBdQE8C0BDAHggM6hEkB2AbtHIdAHSgCSqxADHQCwCsoqCAxgGtQhBC1AA_dgEYApKABmcAPYBbXjF7KADqGgATJNAA0AKBCgcZfRthJEN_soA2znNtrFUy26ABGyqjeqgwAStCqylSgAAYIlNS0AFy8cACu0DFaoE6q2jhw9KY6fMpkoAC8oADepqCg9gj6KdWgymmo1ABC7daEALLK-tApAOSEOKrQo8ZtHd29-oQAwmWoOPFj-EQAMjh-0M6joAC-ZvV4AIIEhC28GNojoKP8OJ1IynAYM6D6bzgpADao0uP1GXTByzBABFRgBdU7nTDXIhAur1Gr3R5jCg4ZwZY5ndH1VqoB5PUa4_HTWbxKg0J6odImUCqTagdgcDgATgAHLNVPgUuwAGy8gBMHFO6LhSNoiGgt1AgOJmLJ2OezniNN-_yB0lYs3FhtAAGYTRxWAiiRi1eSxlqyDqMCjCIxrNA8ClpLM_usgewuLNA0GOXQRcHw1xrTLTCcANymIA

Steps to Reproduce
  1. Open the link above. The right y-axis has inverse: true, min: 0.4498, max: 0.6824, and the grid uses outerBoundsMode: 'same' with outerBoundsContain: 'axisLabel'.
  2. Compare with the same option without inverse: true.
option = {
  grid: { outerBoundsMode: 'same', outerBoundsContain: 'axisLabel' },
  xAxis: { type: 'category', data: ['A', 'B', 'C', 'D'] },
  yAxis: [
    { type: 'value' },
    { type: 'value', inverse: true, min: 0.4498, max: 0.6824 }
  ],
  series: [
    { type: 'line', data: [10, 20, 30, 40] },
    { type: 'line', yAxisIndex: 1, data: [0.5, 0.55, 0.6, 0.65] }
  ]
};
Current Behavior

The grid collapses to the bottom of the chart. In a 600×400 container it is 64px tall.

Expected Behavior

The grid is the same height as without inverse: true (229px in a 600×400 container).

Environment
- OS: macOS
- Browser: Chrome
- Framework: React
Any additional comments?

layOutGridByOuterBounds in src/coord/cartesian/Grid.ts computes each label's proportion with axis.scale.normalize(...) but doesn't account for axis.inverse. On the inverted axis above, the 0.45 tick sits ~0.1% from the top edge but is treated as ~0.1% from the bottom, so applyProportion divides its few px of overhang by ~0.001 and the grid shrinks to its minimum.

Flipping the proportion for inverted axes fixes it (we ship this as a local patch):

let proportion = axis.scale.normalize(
    getTickValueOutermost(axis.scale, getLabelInner(labelInfo.label).labelInfo.tick)
);
if (axis.inverse) {
    proportion = 1 - proportion;
}
proportion = xyIdx === 1 ? 1 - proportion : proportion;

Also reproduces on 6.0.0, and the code is unchanged on master.

Ngôn ngữ chính
TypeScript
Star
67.7k
Fork
19.9k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/echarts

Tất cả issue của apache/echarts

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.