原文地址:http://hao.jobbole.com/ios-charts/
ios-charts是一个强大的图表框架,MPAndroidChart在 iOS 上的移植。
主要功能
线形图(有图例,简单的设计)


线形图(平滑曲线)

线形图(渐变填充)

复合图表(直方图与线形图相结合)

直方图(有图例,简单的设计)

直方图(分组展示数据)

水平直方图

饼状图(分块可选)

散点图(可以使用方形、三角形、圆形等)

烛柱图(用于金融数据)

气泡图(根据气泡表示的值的大小来确定气泡的大小)

雷达图(蜘蛛网状的图表)

安装
通过CocoaPods安装:
在你的 Podfile 文件中添加pod 'Charts',“Charts” 是库的名字。
Realm支持在 Podfile 文件中指定子模块:
pod 'Charts/Realm'
1
pod'Charts/Realm'
注意:pod 'ios-charts'无法导入正确的库,它指向的是另外一个工程。
通过Carthage安装:
Charts 包含了 Carthage 预编译库。
github "danielgindi/ios-charts" == 2.2.3
github "danielgindi/ios-charts" ~> 2.2.3
1
2github"danielgindi/ios-charts"==2.2.3
github"danielgindi/ios-charts"~>2.2.3
为了建立一个新版本的库,请使用carthage build --no-skip-current && carthage archive Charts && carthage archive ChartsRealm。
使用
为了能够正确编译:
1、将Charts.xcodeproj文件拖拽到你的工程中
2、在 TARGETS —> General —> Embedded Binaries 下,点击+按钮,选择 Charts.framework
3、临时解决方法:Xcode 6.3.1中有一个 bug ,在使用@import导入头文件之前必须先进行编译,所以请先点击 “Build” 进行编译
4、@import Charts
5、如果需要在 ObjC 的工程中使用 Swift 文件:
你需要导入 Bridging Header 文件。通常 Bridging Header 文件被命名为
“YourProject-Swift.h”,因此在 ChartsDemo 中是
“ChartsDemo-Swift.h”。不要在你自己的工程中使用 “ChartsDemo-Swift.h” 进行导入。
在 TARGETS —> Build Settings 下搜索 “Embedded Content Contains Swift Code” ,并将其修改为 Yes 。
6、如果需要使用Realm.io:
注意 Realm 框架并没有链接到 Charts ——只是进行了可选绑定。这意味着使用 Charts 时需要在工程中包含 Realm 框架,并且要使用一个兼容的版本。我们会尽最大努力在新的版本中解决这个问题。
开发资源
网友评论