原創|使用教程|編輯:龔雪|2014-05-21 09:47:34.000|閱讀 869 次
概述:本文對使用amCharts ObjC Wrapper for iOS / OS X應用程序生成圖表步驟進行說明。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
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];
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 JavaScript Charts
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件網