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

Custom offsets #562

Closed
mathiasgithub opened this issue Nov 21, 2015 · 2 comments
Closed

Custom offsets #562

mathiasgithub opened this issue Nov 21, 2015 · 2 comments

Comments

@mathiasgithub
Copy link

There always seem to be a 10 point offset on the left and right of my charts and can't figure out how to set this to 0.

I've tried to following but couldn't get it to work:

viewPortHandler.restrainViewPort(offsetLeft: 0, offsetTop: 0, offsetRight: 0, offsetBottom: 0)

Does anyone know how to work this out?

Cheers

@liuxuan30
Copy link
Member

try these:

    /// An extra offset to be appended to the viewport's top
    public var extraTopOffset: CGFloat = 0.0

    /// An extra offset to be appended to the viewport's right
    public var extraRightOffset: CGFloat = 0.0

    /// An extra offset to be appended to the viewport's bottom
    public var extraBottomOffset: CGFloat = 0.0

    /// An extra offset to be appended to the viewport's left
    public var extraLeftOffset: CGFloat = 0.0

They are used before restrainViewPort:

            offsetTop += self.extraTopOffset
            offsetRight += self.extraRightOffset
            offsetBottom += self.extraBottomOffset
            offsetLeft += self.extraLeftOffset

            _viewPortHandler.restrainViewPort(
                offsetLeft: max(self.minOffset, offsetLeft),
                offsetTop: max(self.minOffset, offsetTop),
                offsetRight: max(self.minOffset, offsetRight),
                offsetBottom: max(self.minOffset, offsetBottom))

@liuxuan30 liuxuan30 reopened this Nov 23, 2015
@liuxuan30
Copy link
Member

ah, sorry, I notice there is a max for it. minOffset is 10.0. Then you can simply call
chartView.minOffset = 0.0, and you can do a simple math to make sure they are 0.0 should be enough

It's a little tricky here.. @danielgindi what do you think

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

2 participants