This is pie chart that is very easy to use and customizable design.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
CSPieChart version up Sep 20, 2018
Example version up Sep 20, 2018
.gitignore gitignore 수정 Apr 18, 2017
.swift-version swift version up Sep 20, 2018
CSPieChart.podspec version up Sep 20, 2018
LICENSE Create pod project Jan 4, 2017
README.md version up Sep 20, 2018
_Pods.xcodeproj Create pod project Jan 4, 2017

README.md

CSPieChart

Carthage compatible Version License iOS 8.3+ Swift 4.2+

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

CSPieChart is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "CSPieChart"

Useage

First Step - import CSPieChart to your project

Second Step - You should CSPieChartData. This is model for piechart.

  let data = CSPieChartData(key: "test", value: 70)

Third Step - Add a delegate CSPieChartDataSource & CSPieChartDelegate to your class & add two delegate methods

public protocol CSPieChartDataSource {

    ///  Component data
    func numberOfComponentData() -> Int
    func pieChart(_ pieChart: CSPieChart, dataForComponentAt index: Int) -> CSPieChartData

    ///  Component colors
    func numberOfComponentColors() -> Int
    func pieChart(_ pieChart: CSPieChart, colorForComponentAt index: Int) -> UIColor

    ///  If you are implement this, you can show subView. example) 'UIImageView' or 'UILable'
    @objc optional func numberOfComponentSubViews() -> Int
    @objc optional func pieChart(_ pieChart: CSPieChart, viewForComponentAt index: Int) -> UIView

    ///  If you are implement this, you apply color to line path
    ///  Otherwish line color is applied default 'black'
    @objc optional func numberOfLineColors() -> Int
    @objc optional func pieChart(_ pieChart: CSPieChart, lineColorForComponentAt index: Int) -> UIColor
}
public protocol CSPieChartDelegate {

    /// Component select
    @objc optional func pieChart(_ pieChart: CSPieChart, didSelectComponentAt index: Int)
}

You can set some options

    //  Pie chart radius rate that is percentage of frames in the superview. default is 0.7
    public var pieChartRadiusRate: CGFloat = 0.7
    
    // Pie chart line length between component and subview. default is 10
    public var pieChartLineLength: CGFloat = 10
    
    //  This is piechart component selecting animation. default is none
    public var seletingAnimationType: SelectingAnimationType = .none
}

Last Step - You must call show.

Example

  func ViewDidLoad(...) {
      ....
      pieChart.show(animated: true)
  }

If you need more information, check example

Author

chansim.youk, dbrckstla@naver.com

License

CSPieChart is available under the MIT license. See the LICENSE file for more info.