Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Cleanup: generate axis ticks in-range instead of pruning after the fact (follow-up to #634)

Aperta
#997 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
java

Direzione di ricerca

Inizia con AxisTickCalculator_.calculate(), AxisTickLabels e PlotSurface_AxesChart, quindi esamina PR #996 e RegressionIssue634Test. Confronta gli approcci al clipping e alla generazione dei valori nell’intervallo, preservando ove possibile la densità di tick esistente. Il lavoro è completato quando il test di regressione ha esito positivo, la spaziatura della galleria rimane invariata e i formatter non vengono chiamati per valori fuori intervallo.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Follow-up / tech-debt cleanup from the fix for #634 (PR #996).

Context

#634 was a negative Y-axis label appearing with all-positive data. Root cause: AxisTickCalculator_.calculate() deliberately overshoots the tick range — getFirstPosition() starts one grid step below minValue and the loop runs to maxValue + 2*gridStep — and the tick-label renderer (AxisTickLabels) clips only to the taller axis-column bounds, so overshoot labels leak into the plot margin. (Gridlines and tick marks already clip correctly to the plot bounds in PlotSurface_AxesChart.)

PR #996 fixed the visible bug by pruning ticks outside the data band [margin, margin+tickSpace] after the generation do-while settles. That was chosen deliberately to be behavior-preserving: pruning post-loop leaves the grid-step selection heuristics (areAllTickLabelsUnique / willLabelsFitInTickSpaceHint) seeing the exact same full set as before, so tick density on existing charts is unchanged.

What this issue tracks

Do the structurally cleaner version when there's time to validate it more broadly:

  1. Preferred: make AxisTickLabels clip tick labels to the plot-content band, the same way PlotSurface_AxesChart already clips gridlines and tick marks — so all three consumers of the tick list clip consistently, instead of the calculator emitting values one consumer must drop.

    or

  2. Generate ticks in-range from the start (fix getFirstPosition + the loop upper bound to emit exactly the nice multiples within [minValue, maxValue]), removing the overshoot entirely.

Why it wasn't done in #996
  • Changing generation inputs (option 2) alters what the termination heuristics see, which can change the selected grid step / tick density on charts that never had the bug — a wide regression surface with no pixel-baseline tests to catch it.
  • Option 1 needs the plot-content band (margin / tickSpace) plumbed into AxisTickLabels, which doesn't currently have it.
Bonus wart to fix along the way

With the current pruning approach, the user's tick-label formatting function is still called on the out-of-range values during generation (label computed, then discarded). A generate-in-range approach would avoid invoking the formatter on values outside the data band — relevant if a formatter has side effects or throws on unexpected inputs.

Acceptance
  • No regression to #634 (add-only; RegressionIssue634Test still passes).
  • Tick density/spacing unchanged across the demo gallery (needs a render pass to confirm).
  • Formatting function is not invoked for values outside [minValue, maxValue].
Lingua principale
Java
Stelle
1.6k
Fork
399
Merge medio
6g 15h
PR unite (30g)
4

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di knowm/XChart

Tutte le issue di knowm/XChart

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.