Search code examples
iosios-charts

Can a PieChart from iOS-charts be drawn from a different starting angle than top dead center?


A PieChart from the iOS-charts library is drawn starting from top dead center (90 degrees scientific) and clockwise for every next section of the pie. Is it possible to start at a different angle?

Also a user can rotate the chart on screen, how can that be disabled?


Solution

  • 1)

    Check out the "rotationAngle property of your pieCharView. The documentation for that property says:

    /// current rotation angle of the pie chart
    ///
    /// **default**: 270 --> top (NORTH)
    /// - returns: will always return a normalized value, which will be between 0.0 < 360.0
    

    So try resetting the angle programmatically via something like:

        self.pieChartView.rotationAngle = 180.0
    

    2)

    There's a rotationEnabled property on the chart that you can set to false to disable rotation.