MultiTypeCircleChart
百分比滑动模板的圆图。可用于图表、图形、报告、数据可视化、演示。
需求
- Xcode 8.0+
- Swift 4.0+
安装
MTCircleChart 通过 CocoaPods 提供。您可以使用以下命令进行安装:
$ gem install cocoapods
platform :ios, '9.0'
use_frameworks!
target '<Your Target Name>' do
pod 'MTCircleChart'
end
然后,运行以下命令:
$ pod install
示例
import MTCircleChart
class ViewController: UIViewController {
let circleChart: MTCircleChart = {
let mainColor = UIColor(red: 185/255, green: 212/255, blue: 235/255, alpha: 1.0)
let textColor = UIColor(red: 75/255, green: 118/255, blue: 176/255, alpha: 1.0)
let v = MTCircleChart(tracks: [
MTTrack(value: 86, total: 100, color: mainColor, text: "CONNECTICUT"),
MTTrack(value: 82, total: 100, color: mainColor.withAlphaComponent(0.75), text: "ALABAMA"),
MTTrack(value: 75, total: 100, color: mainColor.withAlphaComponent(0.45), text: "NEVADA"),
MTTrack(value: 70, total: 100, color: mainColor.withAlphaComponent(0.15), text: "UTAH")
], MTConfig(textColor: textColor))
v.translatesAutoresizingMaskIntoConstraints = false
v.backgroundColor = .white
return v
}()
// MARK: View Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(circleChart)
layout()
}
// MARK: Layout
private func layout() {
NSLayoutConstraint.activate(
NSLayoutConstraint.constraints(withVisualFormat: "H:|[view]|", options: [], metrics: nil, views: ["view": circleChart])
)
NSLayoutConstraint.activate(
NSLayoutConstraint.constraints(withVisualFormat: "V:|[view]|", options: [], metrics: nil, views: ["view": circleChart])
)
}
}
许可
MTCircleChart 按照 MIT 许可发布。有关详细信息,请参阅 LICENSE。