OHLC: first and last candles are clipped at the plot edges
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 68/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- java
調査の方向性
PlotContent_OHLC.doPaint から始め、特に xTransform の計算とローソク足の幅の扱いを確認してください。幅の広いローソク足が4本あるチャートで問題を再現し、PR #991 に関連するテストカバレッジを調べてください。完了条件は、既存の OHLC の動作を後退させることなく、最初と最後のローソク足がプロット領域内に完全に描画されることです。
索引モデルが issue の本文から書いたものです。
説明
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()default0.92→ ~4% of width per side). The candle half-width isxTickSpace / 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.
- 主要言語
- Java
- スター
- 1.6k
- フォーク
- 399
- 平均マージ
- 1日 12時間
- マージ済み PR(30日)
- 3
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
knowm/XChart のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
`CategoryChart.addSeries` could support additional call signature for interoperability with Scalaオープン
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
-
Annotationsオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
-
Aesthetics Feature Request
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
-
Feature Request
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
code-maintenance
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
krizaka/krizaka-notifications#32 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
klikli-dev/occultism#1719 ·