一个简单可方便快捷画出折线图、饼图、进度条、柱状图、雷达图的iOS库(Objective-C版本)。新库刚开始维护,希望大家多多支持,可issue、pull request
、find bug
、feature request
。GitHub地址。
还有别忘了 star :-)
持续更行中……
目前
EasyCharts
copy进项目#import "EasyCharts.h"
下面介绍一下几种图的基本使用
BrokenLineChart目前有两种类型BrokenLineTypeCenterPoint
和BrokenLineTypeNormal
。
BrokenLineTypeNormal
是普通的折线图 \
BrokenLineTypeCenterPoint
选中的点始终居中
创建时除了BrokenLineType
还有两个参数,一个是frame
,另一个是ECBrokenLineConfig
(参数如下)对象。
ECBrokenLineConfig
可配置折线图的属性,属性都有默认值。当然可以传nil
,全部被使用默认值
@property (nonatomic, strong) UIColor *brokenLineColor;
@property (nonatomic, strong) UIColor *backVeiwLineColor;
@property (nonatomic, strong) UIColor *backVeiwTextColor;
@property (nonatomic, strong) UIColor *backVeiwBackGroupColor;
@property (nonatomic, strong) UIColor *brokenAbscissaColor;
@property (nonatomic, assign) CGFloat minValue; //default 0
@property (nonatomic, assign) CGFloat maxValue; //default 100
@property (nonatomic, assign) CGFloat numberOfIntervalLines; //default 5
@property (nonatomic, assign) BrokenLineType brokenLineType;
delegate,在当前折线图上的点被点击时调用:
- (void)brokenLineView:(ECBrokenLineView *)brokenLineView
selectedAtIndexPath:(NSIndexPath *)indexPath;
初始化:
ECBrokenLineView *brokenLineView = [ECBrokenLineView lineViewWithFrame:frame
withBrokenLineConfig:nil
brokenLineType:BrokenLineTypeNormal];
brokenLineView.delegate = self;
[self.view addSubview:brokenLineView];
ECBrokenLineView *brokenLineView = [ECBrokenLineView lineViewWithFrame:frame
withBrokenLineConfig:nil
brokenLineType:BrokenLineTypeCenterPoint];
brokenLineView.delegate = self;
[self.view addSubview:brokenLineView];
填充数据(也可刷新页面数据)(数值小于最小值,则值显示为最小值,点两边为虚线。值大于最大值,则显示最大值,点两边为虚线):
[self.brokenLineView reloadLineViewDataWithPointValveList:self.pointValveList
titleText:self.pointTextList];
BrokenLineTypeNormal 效果图:
BrokenLineTypeCenterPoint 效果图:
初始化只需要传入frame
ECProgressChartView *progressView = [ECProgressChartView progressChartViewWithFrame:frame];
[self.view addSubview:progressView];
填充数据(也可刷新页面数据);
[self.progressView resetProgress:[self createProgress]];
效果图:
简单看一下应用场景:
初始化只需要传入frame
ECPieChartView *pieView = [ECPieChartView pieChartViewWithFrame:CGRectMake(0, 100, ECScreenW, 200)];
[self.view addSubview:pieView];
填充数据(也可刷新页面数据);三个参数,分别是百分比列表、颜色列表、文案列表
[pieView drawPieChartWithPercentList:self.percentList
colorList:self.colorList
arcTextList:self.arcTextList];
效果图:
EasyCharts
输出代码,请拼命Pull Requests
我