chart gif GitHub地址HLChartView
cocoa pods 使用
pod 'HLChartView'
1.折线图或曲线图 HLLineChartView
/** y轴值,必传 */
@property(nonatomic,strong) NSArray*yValueLabels;
/** x轴坐标,必传 */
@property(nonatomic,strong) NSArray*xLabels
如何使用
HLLineChartView *lineChartView = [[HLLineChartView alloc]initWithFrame:CGRectMake(0, 100, kScreen_Width, 300)];
NSArray *arr1 = @[@"3",@"4.3",@"10.2",@"5",@"15",@"3",@"4.3",@"10.2",@"5",@"1"];
NSArray *arr2 = @[@"2",@"6.3",@"6.2",@"15",@"10",@"2",@"14.3",@"5.2",@"11",@"4"];
HLLineChartData *data1 = [HLLineChartData lineChartDataWithValuesArray:arr1 lineColor:[UIColor redColor]];
data1.yValuesColor = [UIColor greenColor];
data1.lineWidth = 3.0f;
data1.circleSize = 5;
data1.circleType = HLLineDataCircleTypeCircle;
HLLineChartData *data2 = [HLLineChartData lineChartDataWithValuesArray:arr2 lineColor:[UIColor blueColor]];
lineChartView.yValueLabels = @[data1,data2];
lineChartView.xLabels = @[@"中通快递123",@"圆通快递1",@"顺丰快递1222222222222222222222222",@"邮政快递2111",@"韵达快递22222",@"中通快递11111",@"圆通快递",@"顺丰快递",@"邮政快递",@"韵达快递"];
[self.view addSubview:lineChartView];
lineChartView.yLablesColor = [UIColor greenColor];
lineChartView.xLabelsColor = [UIColor blueColor];
// lineChartView.lineChartType = HLLineChartTypeBrokenLine;
lineChartView.ySepLabelCount = 10;
// lineChartView.xLabelsWidth = 30;
// lineChartView.xLabelsHeight = 20;
// lineChartView.lineColor = [UIColor brownColor];
// lineChartView.isHideYLabels = YES;
// lineChartView.isHideXLables = YES;
lineChartView.isShowGradientColor = NO;
// lineChartView.isShowXSepratorLine = NO;
// lineChartView.isShowYSepratorLine = NO;
// lineChartView.isAnimatedDisplay = NO;
[lineChartView strokeStart];
2.饼图HLPieChartView
如何使用
HLPieChartData *data1 = [HLPieChartData pieDataWithValue:@"20" pieChartColor:[UIColor redColor] detailText:@"中通快递"];
HLPieChartData *data2 = [HLPieChartData pieDataWithValue:@"10.2" pieChartColor:[UIColor blueColor] detailText:@"韵达快递"];
HLPieChartData *data3 = [HLPieChartData pieDataWithValue:@"30.33" pieChartColor:[UIColor purpleColor] detailText:@"圆通快递"];
HLPieChartData *data4 = [HLPieChartData pieDataWithValue:@"5" pieChartColor:[UIColor greenColor] detailText:@"顺丰快递"];
HLPieChartData *data5 = [HLPieChartData pieDataWithValue:@"8" pieChartColor:[UIColor cyanColor] detailText:@"邮政快递"];
HLPieChartView *pieChart = [[HLPieChartView alloc]initWithFrame:CGRectMake(0, 64, kScreen_Width, kScreen_Width)];
pieChart.pieDatas = @[data1,data2,data3,data4,data5];
pieChart.outerCircleRadius = 120;
pieChart.interCircleRadius = 40;
// pieChart.isAnimatedDisplay = NO;
pieChart.lengendPosition = HLPieLengendPositionBottom;
// pieChart.pieDetailTextType = HLPieDetailTextTypeValue;
// pieChart.showLengendView = NO;
pieChart.titleText = @"这是今天收到的快递";
[pieChart strokeStart];
[self.view addSubview:pieChart];
3.可自定义单级多级柱状图
如何使用
HLHistogramData *data1 = [HLHistogramData histogramDataWithValue:@"100" histogramColor:[UIColor redColor]];
HLHistogramData *data2 = [HLHistogramData histogramDataWithValue:@"30" histogramColor:[UIColor blueColor]];
HLHistogramData *data3 = [HLHistogramData histogramDataWithValue:@"50" histogramColor:[UIColor greenColor]];
HLHistogramData *data4 = [HLHistogramData histogramDataWithValue:@"120" histogramColor:[UIColor purpleColor]];
HLHistogramData *data11 = [HLHistogramData histogramDataWithValue:@"80" histogramColor:[UIColor redColor]];
HLHistogramData *data22 = [HLHistogramData histogramDataWithValue:@"20" histogramColor:[UIColor blueColor]];
HLHistogramData *data33 = [HLHistogramData histogramDataWithValue:@"165" histogramColor:[UIColor greenColor]];
HLHistogramData *data44 = [HLHistogramData histogramDataWithValue:@"60" histogramColor:[UIColor purpleColor]];
HLHistogramView *histogramView = [[HLHistogramView alloc]initWithFrame:CGRectMake(0, 100, kScreen_Width, 300)];
histogramView.yValueLabels = @[@[data1,data2,data3],@[data1,data2,data3,data4],@[data11,data22],@[data33,data44],@[data11,data22,data33,data44],@[data1,data2,data33,data44]];
histogramView.xLabels = @[@"1月底层、架构、音视频、逆向",@"2月底视频逆向",@"3月底层、音视频、逆向",@"4月底层、音视频、逆向",@"5月底层、架构、音视频、逆向",@"6月底层"];
histogramView.xHistogramMinGap = 0;
// histogramView.xHistogramMaxGap = 40;
// histogramView.histogramWidth = 30;
// histogramView.ySepLabelCount = 6;
// histogramView.yLabelWidth = 50;
[histogramView strokeStart];
[self.view addSubview:histogramView];
使用问题,请赐教,万分感谢