Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open
#992 1 comment 0 reactions 0 assignees View on GitHub

@timmolter is already working on this.

Since Aug 21, 2026.

  • #1027 by @timmolter — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
java

Research direction

Start in PlotContent_OHLC.doPaint, especially the xTransform calculation and candle width handling. Reproduce the issue with a chart containing four wide candles and inspect the related test coverage from PR #991. Done means the first and last candles render fully inside the plot area without regressing the existing OHLC behavior.

Written by the indexing model from the issue text.

Description

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.

Dominant language
Java
Stars
1.6k
Forks
398
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from knowm/XChart

All issues in knowm/XChart

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.