项目介绍:
如何使用-SCChart 折线图, 柱状图, 圆环图, 圆饼图导入主头文件[Objective-C] 查看源文件 复制代码
#import "SCChart.h"
一.折线图和柱状图1.实例化 ( SCChartLineStyle | SCChartBarStyle )[Objective-C] 查看源文件 复制代码
SCChart *chartView = [[SCChart alloc] initwithSCChartDataFrame:CGRectMake(10, 10, [UIScreen mainScreen].bounds.size.width - 20, 150) withSource:self withStyle:SCChartLineStyle];
2.设置横坐标标题[Objective-C] 查看源文件 复制代码
- (NSArray *)SCChart_xLableArray:(SCChart *)chart { return 横坐标数组;}
3.设置数值(多重数组, 纵坐标标题动态计算)[Objective-C] 查看源文件 复制代码
- (NSArray *)SCChart_yValueArray:(SCChart *)chart { return @[数组1,数组2];}
4.设置折现颜色[Objective-C] 查看源文件 复制代码
- (NSArray *)SCChart_ColorArray:(SCChart *)chart { return @[SCBlue,SCRed,SCGreen];}
5.是否显示间隔线条(折线图专用)[Objective-C] 查看源文件 复制代码
- (BOOL)SCChart:(SCChart *)chart ShowHorizonLineAtIndex:(NSInteger)index { return YES;}
二.圆环图1.实例化[Objective-C] 查看源文件 复制代码
SCCircleChart *chartView = [[SCCircleChart alloc] initWithFrame:CGRectMake(0, (self.frame.size.height-100)/2, SCREEN_WIDTH, 100.0) total:@100 current:@60 clockwise:YES];
2.设置圆环颜色[Objective-C] 查看源文件 复制代码
[chartView setStrokeColor:SCBlue];
3.画线[Objective-C] 查看源文件 复制代码
[chartView strokeChart];
三.圆饼图1.设置数值并实例化[Objective-C] 查看源文件 复制代码
NSArray *items = @[[SCPieChartDataItem dataItemWithValue:10 color:SCRed description:@"A"], [SCPieChartDataItem dataItemWithValue:20 color:SCBlue description:@"B"], [SCPieChartDataItem dataItemWithValue:40 color:SCGreen description:@"C"], ];SCPieChart *chartView = [[SCPieChart alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-150)/2, (self.frame.size.height-150)/2, 150.0, 150.0) items:items];
2.设置描述文字[Objective-C] 查看源文件 复制代码
chartView.descriptionTextColor = [UIColor whiteColor];chartView.descriptionTextFont = [UIFont fontWithName:@"Avenir-Medium" size:12.0];
3.画线[Objective-C] 查看源文件 复制代码
[chartView strokeChart];
DEMO 下载: