Skip to content
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

How to control which entries on xAxis be shown? #768

Closed
bakso opened this issue Feb 21, 2016 · 6 comments
Closed

How to control which entries on xAxis be shown? #768

bakso opened this issue Feb 21, 2016 · 6 comments

Comments

@bakso
Copy link

bakso commented Feb 21, 2016

Well, I have many entries in the xAxis, for example :

9:30
9:31
9:32
...
10:00
10:01
...
11:30

But I only want to show 9:30 and 10:30 and 11:30 on the xAxis, the entries are equidistant and must be the chosen ones, how to do with it ? Thanks

@bakso
Copy link
Author

bakso commented Feb 21, 2016

By the way, the last entry label on xAxis(11:30) always invisible, how to make it visible?

@liuxuan30
Copy link
Member

the x axis labels are controlled by some logic called axisLabelModulus. if you let ios-charts calculates it, it will calculate the axisLabelModulus to a proper value to let the labels display properly. If you use resetLabelsToSkip(), then you should be able to show 9:30, 10:30, etc.

About the last one disappearing, try avoidFirstLastClippingEnabled = true.

    /// the modulus that indicates if a value at a specified index in an array(list) for the x-axis-labels is drawn or not. Draw when `(index % modulus) == 0`.
    public var axisLabelModulus = Int(1)

    /// if set to true, the chart will avoid that the first and last label entry in the chart "clip" off the edge of the chart
    public var avoidFirstLastClippingEnabled = false

    /// Sets the number of labels that should be skipped on the axis before the next label is drawn. 
    /// This will disable the feature that automatically calculates an adequate space between the axis labels and set the number of labels to be skipped to the fixed number provided by this method. 
    /// Call `resetLabelsToSkip(...)` to re-enable automatic calculation.
    public func setLabelsToSkip(count: Int)
    {
        ...
    }

@bakso
Copy link
Author

bakso commented Feb 22, 2016

avoidFirstLastClippingEnabled make first and last label not clipped any more.

@danielgindi
Copy link
Collaborator

That's not the first/last that's clipped explicitly - but the whole drawing
region. That should be controlled using a different flag...
בתאריך יום ב׳, 22 בפבר׳ 2016 ב-17:01 מאת Gabe Tse <notifications@github.com

:

avoidFirstLastClippingEnabled make first and last label not clipped any
more.


Reply to this email directly or view it on GitHub
#768 (comment)
.

@vrobles2008
Copy link

@liuxuan30 How would I use the resetLabelToSkip() method?

@liuxuan30
Copy link
Member

it's deprecated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants