OHLC: first and last candles are clipped at the plot edges

Đã đóng
#992 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

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

Từ ngày 21/8/2026.

  • #1027 của @timmolter — đang mở

Đánh giá

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

Hướng nghiên cứu

Bắt đầu trong PlotContent_OHLC.doPaint, đặc biệt là phần tính toán xTransform và xử lý độ rộng của nến. Tái hiện vấn đề với một biểu đồ chứa bốn nến rộng và kiểm tra độ bao phủ kiểm thử liên quan từ PR #991. Được xem là hoàn tất khi nến đầu tiên và nến cuối cùng được kết xuất đầy đủ bên trong vùng vẽ mà không làm hồi quy hành vi OHLC hiện có.

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

Mô tả

Aesthetics

Description

In an OHLC candlestick chart, the x-axis range is set to exactly [dataMin, dataMax]. As a result, the first and last candles are centered on the plot's left/right boundaries, so roughly half of each edge candle body extends past the plot content area and is clipped.

Reproduction

A chart with few, wide candles makes this obvious (e.g. 4 candles) — the leftmost and rightmost candle bodies are visibly cut in half by the plot border. See screenshot discussion in #734 / PR #991.

Root cause

  • The first data point (x = xMin) maps to the left edge of the tick space and the last (x = xMax) to the right edge — PlotContent_OHLC.doPaint (xTransform = xLeftMargin + ((x - xMin) / (xMax - xMin) * xTickSpace)).
  • Each candle is drawn centered on that point, extending ±candleHalfWidth.
  • The only slack is the plot-content margin (getPlotContentSize() default 0.92 → ~4% of width per side). The candle half-width is xTickSpace / xData.length / 2, which for a small number of candles greatly exceeds that margin, so the edge candles overrun the boundary.

With realistic OHLC data (many narrow candles) the overrun is a thin sliver and largely unnoticeable, which is likely why it hasn't been reported before.

Suggested fix

Pad the x-axis range (or the mapped plot area) by ~half a candle width on each side, as most candlestick charting libraries do, so the first and last candles render fully inside the plot. This should be independent of the candle count.

Notes

Discovered while adding test coverage in PR #991 (issue #734, doji candles). This clipping is a pre-existing, general OHLC rendering behavior, unrelated to the doji fix.

Ngôn ngữ chính
Java
Star
1.6k
Fork
400
Merge trung bình
3 ngày 1 giờ
Pull request đã merge (30 ngày)
5

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

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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 knowm/XChart

Tất cả issue của knowm/XChart

Issue tương tự

Thêm issue về Java

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.