彩票走势图

amCharts ObjC Wrapper for iOS/OS X应用程序生成图表教程

原创|使用教程|编辑:龚雪|2014-05-21 09:47:34.000|阅读 827 次

概述:本文对使用amCharts ObjC Wrapper for iOS / OS X应用程序生成图表步骤进行说明。

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

相关链接:

在上一节中,我们介绍了开源AmCharts图表库本地ObjC Wrapper for iOS / OS X,这一节,我们为大家带来具体的使用示例。

生成图表

AmChart框架或者图表库在项目中,生成图表非常简单。导入框架:

#import <AmCharts/AmCharts.h>

如果您正在构建一个iOS应用程序使用这个:

#import <AmCharts/AmCharts.h>

添加  AmChartView (从 Webview 继承)或者  AmMobileChartView (从 UIView 继承)。

AmPieChart *pieChart = [[AmPieChart alloc] init];
pieChart.type = @"pie";
pieChart.theme = @"none";
NSMutableArray *dataProvider = [[NSMutableArray alloc] init];
[dataProvider addObject:@{@"country" : @"Lithuania", @"litres" : @(501.9)}];
[dataProvider addObject:@{@"country" : @"Czech Republic", @"litres" : @(301.9)}];
[dataProvider addObject:@{@"country" : @"Ireland", @"litres" : @(201.1)}];
pieChart.dataProvider = dataProvider;

pieChart.valueField = @"litres";
pieChart.titleField = @"country";

// where self.chartView references an AmChartView *
[self.chartView setChart:pieChart];
[self.chartView drawChart];

饼图

AmCharts

柱形图:

AmSerialChart *chart = [[AmSerialChart alloc] init];
chart.type = @"serial";
chart.dataProvider = [@[@{@"year" : @"2005", @"income" : @"23.5"},
                       @{@"year" : @"2006", @"income" : @"26.2"},
                        @{@"year" : @"2007", @"income" : @"30.1"},
                        @{@"year" : @"2008", @"income" : @"32.0"},
                        @{@"year" : @"2009", @"income" : @"31.6"},
                        @{@"year" : @"2010", @"income" : @"33.4"},
                        @{@"year" : @"2011", @"income" : @"34.3"},
                        @{@"year" : @"2012", @"income" : @"34.9"},
                        @{@"year" : @"2013", @"income" : @"35.7"}] mutableCopy];
chart.categoryField = @"year";
//chart.rotate = YES;
chart.categoryAxis.gridPosition = @"start";
chart.categoryAxis.axisColor = @"#DADADA";
AmValueAxis *valAxis = [[AmValueAxis alloc] init];
valAxis.axisAlpha = @(0.2);
chart.valueAxes = [@[valAxis] mutableCopy];
chart.balloon = nil;
AmGraph *graph = [[AmGraph alloc] init];
graph.type = @"column";
graph.title = @"Income";
graph.valueField = @"income";
graph.lineAlpha = @(0);
graph.fillColors = @"#ADD981";
graph.fillAlphas = @(0.8);
graph.balloonText = @"[[title]] in [[category]]:<b>[[value]]</b>";
chart.graphs = [@[graph] mutableCopy];

[self.chartView setChart:chart];
[self.chartView drawChart];

效果图:

AmCharts

问题及注意

  • 该文件包含Mac和iOS应用程序示例
  • 相关教程请访问:

>>下载AmCharts JavaScript Charts


标签:JavaScript 图表iOS

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@pclwef.cn

文章转载自:慧都控件网

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP