{"action":"created","issue":{"url":"https://api.github.com/repos/i-schuetz/SwiftCharts/issues/45","labels_url":"https://api.github.com/repos/i-schuetz/SwiftCharts/issues/45/labels{/name}","comments_url":"https://api.github.com/repos/i-schuetz/SwiftCharts/issues/45/comments","events_url":"https://api.github.com/repos/i-schuetz/SwiftCharts/issues/45/events","html_url":"https://github.com/i-schuetz/SwiftCharts/issues/45","id":110565061,"number":45,"title":"Charts do not rotate properly","user":{"login":"RickStreet","id":12189265,"avatar_url":"https://avatars.githubusercontent.com/u/12189265?v=3","gravatar_id":"","url":"https://api.github.com/users/RickStreet","html_url":"https://github.com/RickStreet","followers_url":"https://api.github.com/users/RickStreet/followers","following_url":"https://api.github.com/users/RickStreet/following{/other_user}","gists_url":"https://api.github.com/users/RickStreet/gists{/gist_id}","starred_url":"https://api.github.com/users/RickStreet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RickStreet/subscriptions","organizations_url":"https://api.github.com/users/RickStreet/orgs","repos_url":"https://api.github.com/users/RickStreet/repos","events_url":"https://api.github.com/users/RickStreet/events{/privacy}","received_events_url":"https://api.github.com/users/RickStreet/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-10-09T00:06:15Z","updated_at":"2015-10-09T15:55:04Z","closed_at":null,"body":"Great Library!  The examples look great.  When I rotate, the landscape doesn't fill the frame.  When I rotate back to prostrate, part of the graph is cut off.  This happens with and without using auto layout.\r\n\r\nHere's the ViewController I'm using:\r\n\r\n//  Copyright © 2015 us.rickstreet. All rights reserved.\r\n//\r\n\r\nimport UIKit\r\nimport SwiftCharts\r\n\r\nclass ViewController: UIViewController {\r\n    \r\n    private var chart: Chart? // arc\r\n    \r\n    @IBOutlet weak var chartView: ChartBaseView!\r\n    \r\n    private var didLayout: Bool = false\r\n\r\n    \r\n   override func viewDidLoad() {\r\n        super.viewDidLoad()\r\n        // Do any additional setup after loading the view, typically from a nib.\r\n            NSNotificationCenter.defaultCenter().addObserver(self, selector: \"rotated\", name: UIDeviceOrientationDidChangeNotification, object: nil)\r\n        }\r\n\r\n    override func viewDidLayoutSubviews() {\r\n        super.viewDidLayoutSubviews()\r\n        \r\n        if !self.didLayout {\r\n            self.didLayout = true\r\n            self.initChart()\r\n        }\r\n    }\r\n    \r\n    private func initChart() {\r\n        \r\n        for index in 5.stride(through: 1, by: -1) {\r\n            print(index)\r\n        }\r\n        \r\n        // map model data to chart points\r\n        let chartPoints: [ChartPoint] = [(2, 2), (4, 4), (6, 6), (8, 10), (12, 14)].map{ChartPoint(x: ChartAxisValueInt($0.0), y: ChartAxisValueInt($0.1))}\r\n        \r\n        let labelSettings = ChartLabelSettings(font: ExamplesDefaults.labelFont)\r\n        \r\n        // define x and y axis values (quick-demo way, see other examples for generation based on chartpoints)\r\n        let xValues = 0.stride(through: 16, by: 2).map {ChartAxisValueInt($0, labelSettings: labelSettings)}\r\n        \r\n        let yValues = 0.stride(through: 16, by: 2).map {ChartAxisValueInt($0, labelSettings: labelSettings)}\r\n        \r\n        // create axis models with axis values and axis title\r\n        let xModel = ChartAxisModel(axisValues: xValues, axisTitleLabel: ChartAxisLabel(text: \"Axis title\", settings: labelSettings))\r\n        let yModel = ChartAxisModel(axisValues: yValues, axisTitleLabel: ChartAxisLabel(text: \"Axis title\", settings: labelSettings.defaultVertical()))\r\n        \r\n        let chartFrame = self.chartView.frame\r\n        \r\n        // generate axes layers and calculate chart inner frame, based on the axis models\r\n        let coordsSpace = ChartCoordsSpaceLeftBottomSingleAxis(chartSettings: ExamplesDefaults.chartSettings, chartFrame: chartFrame, xModel: xModel, yModel: yModel)\r\n        let (xAxis, yAxis, innerFrame) = (coordsSpace.xAxis, coordsSpace.yAxis, coordsSpace.chartInnerFrame)\r\n        \r\n        // create layer with guidelines\r\n        let guidelinesLayerSettings = ChartGuideLinesDottedLayerSettings(linesColor: UIColor.blackColor(), linesWidth: ExamplesDefaults.guidelinesWidth)\r\n        let guidelinesLayer = ChartGuideLinesDottedLayer(xAxis: xAxis, yAxis: yAxis, innerFrame: innerFrame, settings: guidelinesLayerSettings)\r\n        \r\n        // view generator - this is a function that creates a view for each chartpoint\r\n        let viewGenerator = {(chartPointModel: ChartPointLayerModel, layer: ChartPointsViewsLayer, chart: Chart) -> UIView? in\r\n            let viewSize: CGFloat = Env.iPad ? 30 : 20\r\n            let center = chartPointModel.screenLoc\r\n            let label = UILabel(frame: CGRectMake(center.x - viewSize / 2, center.y - viewSize / 2, viewSize, viewSize))\r\n            label.backgroundColor = UIColor.greenColor()\r\n            label.textAlignment = NSTextAlignment.Center\r\n            label.text = \"\\(chartPointModel.chartPoint.y.text)\"\r\n            label.font = ExamplesDefaults.labelFont\r\n            return label\r\n        }\r\n        \r\n        // create layer that uses viewGenerator to display chartpoints\r\n        let chartPointsLayer = ChartPointsViewsLayer(xAxis: xAxis, yAxis: yAxis, innerFrame: innerFrame, chartPoints: chartPoints, viewGenerator: viewGenerator)\r\n        \r\n        // create chart instance with frame and layers\r\n        let chart = Chart(\r\n            view: self.chartView!,\r\n            layers: [\r\n                coordsSpace.xAxis,\r\n                coordsSpace.yAxis,\r\n                guidelinesLayer,\r\n                chartPointsLayer\r\n            ]\r\n        )\r\n        self.chart = chart\r\n    }\r\n    \r\n    func rotated() {\r\n        for view in self.chartView.subviews {\r\n            view.removeFromSuperview()\r\n        }\r\n        self.initChart()\r\n    }\r\n\r\n\r\n}\r\n\r\nThanks,\r\nRick\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/i-schuetz/SwiftCharts/issues/comments/146909837","html_url":"https://github.com/i-schuetz/SwiftCharts/issues/45#issuecomment-146909837","issue_url":"https://api.github.com/repos/i-schuetz/SwiftCharts/issues/45","id":146909837,"user":{"login":"i-schuetz","id":1381744,"avatar_url":"https://avatars.githubusercontent.com/u/1381744?v=3","gravatar_id":"","url":"https://api.github.com/users/i-schuetz","html_url":"https://github.com/i-schuetz","followers_url":"https://api.github.com/users/i-schuetz/followers","following_url":"https://api.github.com/users/i-schuetz/following{/other_user}","gists_url":"https://api.github.com/users/i-schuetz/gists{/gist_id}","starred_url":"https://api.github.com/users/i-schuetz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/i-schuetz/subscriptions","organizations_url":"https://api.github.com/users/i-schuetz/orgs","repos_url":"https://api.github.com/users/i-schuetz/repos","events_url":"https://api.github.com/users/i-schuetz/events{/privacy}","received_events_url":"https://api.github.com/users/i-schuetz/received_events","type":"User","site_admin":false},"created_at":"2015-10-09T15:55:04Z","updated_at":"2015-10-09T15:55:04Z","body":"hmm. I could reproduce a cut problem but not related with rotation. The issue in this case it's the way the example view controller's view is added as a child to details view controller. For it to work correctly with autolayout you have to give the example view controller's view the correct frame, so in DetailViewController:\r\n```\r\n    private func showExampleController(controller: UIViewController) {\r\n        if let currentExampleController = self.currentExampleController {\r\n            currentExampleController.removeFromParentViewController()\r\n            currentExampleController.view.removeFromSuperview()\r\n        }\r\n        self.addChildViewController(controller)\r\n        controller.view.frame = self.view.frame // add this line\r\n        self.view.addSubview(controller.view)\r\n\r\n        self.currentExampleController = controller\r\n    }\r\n```\r\nYou can also use autolayout for this. Outside of the example project you will likely not have this problem unless you also have a nested view controller or insufficient constraints.\r\n\r\n\r\n "}}