GSAnalysis 是一个用 Swift 编写的简单分析图形库。它包括类似 Apple Health 的分析图形视图。
要运行示例项目,先克隆仓库,并从 Example 目录运行 pod install
从Storyboard使用它:只需将 UIView 拖放到 Storyboard,并将其类更改为 "GSxxxView" 即可。
您也可以将其作为普通的 UIView 使用
两种方式都需要提供数据源
//Add from storyboard
//In viewDidLayoutSubviews method just incase the layout is correct
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
//Add from storyboard
barChartFromNib.titleLabel.text = "I am from Nib"
barChartFromNib.points = [5,6,7,9]
}
//Add by code
let frame = CGRect(x: barChartFromNib.frame.origin.x, y: barChartFromNib.frame.height + barChartFromNib.frame.origin.y + 50, width: 200, height: 100)
let barChart = GSBarChartView(frame: frame)
barChart.barSpace = 15.0
barChart.barWidth = 50.0
barChart.points = [5,6,7,9]
barChart.barColor1 = UIColor.redColor()
barChart.barColor2 = UIColor.greenColor()
barChart.baseLineColor = UIColor.blueColor()
self.view.addSubview(barChart)
let lineView = GSLineView(frame: CGRect(x: 50,y: 100,width: 300,height: 300))
lineView.points = [4, 2, 6, 4, 5, 8, 3]
lineView.startColor = UIColor(red: 250/255.0, green: 233/255.0, blue: 222/255.0, alpha: 1.0)
lineView.endColor = UIColor(red: 252/255.0, green: 79/255.0, blue: 8/255.0, alpha: 1.0)
self.view.addSubview(lineView)
IOS 8 及以上。
GSAnalysis 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile
pod "GSAnalysis"
William Hu, [email protected]
GSAnalysis 在 MIT 许可证下提供。有关更多信息,请参阅 LICENSE 文件。