-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Labels at specific positions for x and y axis #2692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Hello thanks for your PR and PhilJay for this awesome lib. Will this be useful for horizontal scrollable graphs? I have a use case where I need to be able to display in the X axis 5 years in months just displaying the first 12 at the beginning (visibleXRangeMaximum = 12) and I only want to display 4 labels (xAxis.setLabelCount = 4). This is working perfectly but setLabelCount tries to split the labels as equally as possible. Is there any way I would be able to specify so only the first 4 months of every year are drawn? (for example) Thank you in advance. |
|
@sanogueralorenzo It could work yes, if you know how much years you are drawing (with my PR you must tell the graph exactly which labels should be drawn). For example : Otherwise, if today you are able to display every month, but only wants the first 4 of each year, I suggest creating a custom value formatter and returning an empty string for the months you dont want to display. |
|
@philippeauriach Super job! Just what I was looking for. @PhilJay Any plans on accepting this PR any time soon? This looks like a good value addition to the library. |
|
@philippeauriach Hey Phillipe. I am trying to have a graph where all my labels are plotted( like months in a year or days in a week) but I only have data for a few points i.e (number of entries < number of labels). How do I modify this to correctly plot my entries. Right now with the current implementation, only a certain number of labels are being plotted i.e up to the corresponding entry in the graph with the same x value. So if my x label position max is 50, but the max x position value of an entry is 20, I can only see my labels up to 20. I would like all labels to be plotted so I can scroll the entire length of labels(with a few entries) |
|
@rohangoqii my PR does not modify how the axis is drawn, just which labels at which positions: if you provide label outside of the axis range, they just wont be displayed. |
|
That's exactly what I did!! Thanks @philippeauriach |
…itions Labels at specific positions for x and y axis PhilJay#2692
|
Why hasn't this been merged in yet? @PhilJay |
|
For anyone in the need of this behavior before the branch is merged. This is this PR's code all bundled into one |
|
Thanks to @bakua I found an alternative approach that does not override
|
|
Could you please create a new pull request for this, as the file structure has changed. This looks fine, except I recommend that instead of creating a brand new example activity, please find one existing activity and show it off there without changing the chart too much. Thank you! |
|
Another example for x axis as dates |
(cherry picked from commit c85e212)
(cherry picked from commit c85e212)
This PR allows users to tell the graph which labels should be drawn.
Example :
With this labels will only be drawn for values 0, 10, 20, 50, 100, 300, whatever the size of the graph. This is especially useful for "fixed" graphs, when for example you want to display start and end dates, with only a few between those.
I added an example, see SpecificXLabelsLineChartActivity