Tick labels are packed too dense when there are many equally spaced samples
Maintainers usually reply within 4 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 44/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- java
- Domain
- data-visualization
Research direction
Start at the X-axis tick-generation path and the mentioned willLabelsFitInTickSpaceHint function, then reproduce the issue with several hundred equally spaced samples and compare it with the dummy-sample case. Done means X-axis grid lines and labels are spaced reasonably for dense equally spaced data, while existing Y-axis behavior and custom label formatting remain intact.
Written by the indexing model from the issue text.
Description
Hi,
I use XYChart for real time plotting. Data series usually has several hundred samples. My samples are always equally spaced on X-axis.
The grid lines (and thus tick labels) are packed too dense. Please take a look at the picture below:

By adding just one dummy sample which is not equally spaced I get more reasonable ticks locations. See the picture below:

I tried to use xAxisTickMarkSpacingHint property but it doesn't have any impact on X-axis ticks, but it works well for Y-axis ticks.
I also tried to use setCustomXAxisTickLabelsFormatter to add some space around values, like this:
chart.setCustomXAxisTickLabelsFormatter {
String.format(" %.2f ", it)
}
however trailing spaces are truncated at some point so it doesn't help at all, unless, I add some dummy charater after spaces
chart.setCustomXAxisTickLabelsFormatter {
String.format(" %.2f X", it)
}

I am not familiar with the XChart source code but I believe this problem can be solved/mitigated by increasing required ratio between tickSpacingHint and largestLabelWidth in function willLabelsFitInTickSpaceHint:

Not truncating trailing spaces would be also a nice workaround for this problem
Thanks in advance
- Dominant language
- Java
- Stars
- 1.6k
- Forks
- 400
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 7
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from knowm/XChart
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 4 days
-
Difficulty 3/5 1-2 days Newbie friendliness 57/100
Maintainers usually reply within 4 days
-
Difficulty 3/5 1-2 days Newbie friendliness 67/100
Maintainers usually reply within 4 days
-
Cleanup: generate axis ticks in-range instead of pruning after the fact (follow-up to #634)Possibly taken @Sinkleberg claimed this 20 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Maintainers usually reply within 4 days
-
`CategoryChart.addSeries` could support additional call signature for interoperability with ScalaPossibly taken @Sinkleberg claimed this 20 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Maintainers usually reply within 4 days
Similar issues
-
documentation good first issue help wanted
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 2 days
-
bug key bindings
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Maintainers usually reply within 1 day
-
Android Bug Core Drape
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
organicmaps/organicmaps#14449 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
openhab/openhab-addons#22512 ·
Maintainers usually reply within 1 day