-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Positioning on changing of the screen orientation #786
Comments
I had the same problem and solved it by overriding this method in my Chart-Class: public override func observeValueForKeyPath(
keyPath: String?,
ofObject object: AnyObject?,
change: [String : AnyObject]?,
context: UnsafeMutablePointer<Void>) {
var oldPoint: CGPoint?
if keyPath == "frame" || keyPath == "bounds" {
oldPoint = viewPortHandler.contentRect.origin
getTransformer(.Left).pixelToValue(&oldPoint!)
}
super.observeValueForKeyPath(keyPath, ofObject: object, change: change, context: context)
if var p = oldPoint {
getTransformer(.Left).pointValueToPixel(&p)
viewPortHandler.centerViewPort(pt: p, chart: self)
}
} |
I fixed the md in your comment @leoMehlig, nice solution btw |
Yes, thank you! This patch works fine |
@liuxuan30 is this a feature that should be implemented internally? |
@leoMehlig I'm not sure if everyone has such requirements, some may want keep centered, while some want nothing changed :) If you think it's useful, than add a switch to turn it on and a PR :) |
Hi!
There is a minor drawback, that when screen orientation changes, the vertical scale loses its position and goes to some range around original (previous).
Conditions:
The text was updated successfully, but these errors were encountered: