iOS中的图表(AAChart)使用
2017-06-13 13:49
597 查看
https://github.com/potato512/AAChartKit
效果图:
代码示例:
// 头文件
#import "UIChartView.h"
效果图:
代码示例:
// 头文件
#import "UIChartView.h"
// 定义成属性 @property (nonatomic, strong) UIChartView *chartView;
// 实例化 self.chartView = [[UIChartView alloc] initWithFrame:CGRectMake(0.0, height, self.view.frame.size.width, (self.view.frame.size.height - height)) view:self.view];
// 类型 self.chartView.chartModel.chartTypeSet(AAChartTypeBar);
// 标题,数据等设置 self.chartView.chartTitle = @"编程语言热度"; self.chartView.chartSubTitle = @"虚拟数据"; self.chartView.chartXTitles = @[@"Java", @"Swift", @"Python", @"Objective-C", @"PHP", @"Go"]; self.chartView.chartYTitle = @"摄氏度"; NSMutableArray *array = [NSMutableArray array]; for (int i = 0; i < 4; i++) { ChartModel *model = [ChartModel new]; if (0 == i) { model.name = @"2014"; model.datas = @[@45, @88, @49, @43, @65, @56]; } else if (1 == i) { model.name = @"2015"; model.datas = @[@31, @22, @33, @54, @35, @36]; } else if (2 == i) { model.name = @"2016"; model.datas = @[@11, @12, @13, @14, @15, @16]; } else if (3 == i) { model.name = @"2017"; model.datas = @[@21, @22, @24, @27, @25, @26]; } [array addObject:model]; } self.chartView.charts = array;
// 刷新数据,显示图表 [self.chartView reloadChart];
// 其他属性设置 // 是否显示加载状态 self.chartView.showActivityIndicatorView = YES; // 堆叠类型 NSArray *stackingArr = @[AAChartStackingTypeFalse, AAChartStackingTypeNormal, AAChartStackingTypePercent]; self.chartView.chartModel.stacking = stackingArr[segmentedControl.selectedSegmentIndex]; // 折线连接点形状 NSArray *symbolArr = @[AAChartSymbolTypeCircle, AAChartSymbolTypeSquare, AAChartSymbolTypeDiamond, AAChartSymbolTypeTriangle, AAChartSymbolTypeTriangle_down]; self.chartView.chartModel.symbol = symbolArr[segmentedControl.selectedSegmentIndex]; // x轴翻转 self.chartView.chartModel.xAxisReversed = (switchView.on ? true : false); // y轴翻转 self.chartView.chartModel.yAxisReversed = (switchView.on ? true : false); // x轴直立 self.chartView.chartModel.inverted = (switchView.on ? true : false); // 从中心向四周辐射 self.chartView.chartModel.polar = (switchView.on ? true : false); // 隐藏连接点 self.chartView.chartModel.markerRadius = (switchView.on ? @0 : @5); // 显示数据点 self.chartView.chartModel.dataLabelEnabled = (switchView.on ? true : false);
// 刷新数据,重新绘制图表 [self.chartView refreshChart];
相关文章推荐
- 使用DundasWebChart.dll 版本号:4.1.0.1669 画图表
- 在 Web 页面中使用图表(chart)表现数据
- iOS 使用 Core Plot 绘制统计图表入门
- Flash图表组件——使用Open Flash Chart 2.0的一些问题及解决办法
- 数据图表DBChart的使用
- 如何使用一个不错的图表组件WebChart(免费)
- Nevron Chart教程(2):多轴图表的使用---Nevron Chart图轴对接
- iOS 使用 Core Plot 绘制统计图表入门
- FusionChart图表控件使用说明
- ios开发学习--图表(Chart)效果源码分享--系列教程
- 如何使用一个不错的图表组件WebChart(免费) 用c#编写
- 如何使用一个不错的图表组件WebChart(免费)
- 在ASP中使用ASPChart组件生成图表
- vb.net chart图表使用技巧之一
- chart图表控件的一些使用
- 如何使用一个不错的图表组件WebChart(免费)
- 在 Web 页面中使用图表(chart)表现数据
- 如何使用一个不错的图表组件WebChart(免费)
- iOS 使用 Core Plot 绘制统计图表入门[转]
- 使用DevExpress的WebChartControl控件绘制图表(柱状图、折线图、饼图)