摘要:可選的值有,和。布局類型或即水平布局和垂直布局默認(rèn)是設(shè)定圖例在圖表區(qū)中的水平對(duì)齊方式,合法值有,和。垂直位置可以通過(guò)選項(xiàng)做進(jìn)一步設(shè)定。
https://github.com/AAChartMod...
前言適配 iOS 6, 支持ARC,支持 OC語(yǔ)言,配置簡(jiǎn)單.
功能強(qiáng)大,支持柱狀圖 條形圖 折線圖 填充圖 雷達(dá)圖 扇形圖 氣泡圖等多種圖形
動(dòng)畫效果細(xì)膩精致,流暢優(yōu)美.
支持類 Masonry 鏈?zhǔn)骄幊陶Z(yǔ)法
AAChartView +AAChartModel = Chart,在 AAChartKit 封裝庫(kù)當(dāng)中,遵循這樣一個(gè)極簡(jiǎn)主義公式:圖表視圖控件+圖表模型=你想要的圖表.
真機(jī)美圖Column Chart 柱狀圖 | Columnrange Chart 條形范圍圖 | Area Chart 區(qū)域填充圖 |
---|---|---|
Line Chart 多組數(shù)據(jù)折線圖 | Step Area Chart 直方折線填充圖 | Step Line Chart 直方折線圖 |
---|---|---|
將項(xiàng)目demo中的文件夾AAChartKitLib拖入到所需項(xiàng)目中.
在你的項(xiàng)目的 .pch 全局宏定義文件中添加
#import "AAGlobalMacro.h"正式開(kāi)始
在你的視圖控制器文件中添加
#import "AAChartView.h"
創(chuàng)建視圖AAChartView
AAChartView *chartView = [[AAChartView alloc]init]; self.view.backgroundColor = [UIColor whiteColor]; chartView.frame = CGRectMake(0, 60, self.view.frame.size.width, self.view.frame.size.height-220); chartView.contentHeight =self.view.frame.size.height-220;//設(shè)置圖表視圖的內(nèi)容高度(默認(rèn) contentHeight 和 AAChartView 的高度相同) [self.view addSubview:chartView];
配置視圖模型AAChartModel
AAChartModel *chartModel= AAObject(AAChartModel) .chartTypeSet(AAChartTypeColumn)//設(shè)置圖表的類型(這里以設(shè)置的為柱狀圖為例) .titleSet(@"編程語(yǔ)言熱度")//設(shè)置圖表標(biāo)題 .subtitleSet(@"虛擬數(shù)據(jù)")//設(shè)置圖表副標(biāo)題 .categoriesSet(@[@"Java",@"Swift",@"Python",@"Ruby", @"PHP",@"Go",@"C",@"C#",@"C++"])//設(shè)置圖表橫軸的內(nèi)容 .yAxisTitleSet(@"攝氏度")//設(shè)置圖表 y 軸的單位 .seriesSet(@[ AAObject(AASeriesElement) .nameSet(@"2017") .dataSet(@[@45,@56,@34,@43,@65,@56,@47,@28,@49]), AAObject(AASeriesElement) .nameSet(@"2018") .dataSet(@[@11,@12,@13,@14,@15,@16,@17,@18,@19]), AAObject(AASeriesElement) .nameSet(@"2019") .dataSet(@[@31,@22,@33,@54,@35,@36,@27,@38,@39]), AAObject(AASeriesElement) .nameSet(@"2020") .dataSet(@[@21,@22,@53,@24,@65,@26,@37,@28,@49]), ]) ;
繪制圖形
[chartView aa_drawChartWithChartModel:chartModel];//圖表視圖對(duì)象調(diào)用圖表模型對(duì)象,繪制最終圖形
刷新圖形
[chartView aa_refreshChartWithChartModel:chartModel];//更新 AAChartModel 數(shù)據(jù)之后,刷新圖表
特別說(shuō)明
AAChartKit 中扇形圖、氣泡圖都?xì)w屬為特殊類型,所以想要繪制扇形圖、氣泡圖,圖表模型 AAChartModel 設(shè)置稍有不同,示例如下
繪制扇形圖,你需要這樣配置模型 AAChartModel
AAChartModel *chartModel= AAObject(AAChartModel) .chartTypeSet(AAChartTypePie) .titleSet(@"編程語(yǔ)言熱度") .subtitleSet(@"虛擬數(shù)據(jù)") .dataLabelEnabledSet(true)//是否直接顯示扇形圖數(shù)據(jù) .yAxisTitleSet(@"攝氏度") .seriesSet( @[AAObject(AASeriesElement) .nameSet(@"語(yǔ)言熱度占比") .dataSet(@[ @[@"Java" , @67], @[@"Swift" , @44], @[@"Python", @83], @[@"OC" , @11], @[@"Ruby" , @42], @[@"PHP" , @31], @[@"Go" , @63], @[@"C" , @24], @[@"C#" , @888], @[@"C++" , @66], ]), ] ) ;
繪制氣泡圖,你需要這樣配置模型 AAChartModel
AAChartModel *chartModel= AAObject(AAChartModel) .chartTypeSet(AAChartTypeBubble) .titleSet(@"編程語(yǔ)言熱度") .subtitleSet(@"虛擬數(shù)據(jù)") .yAxisTitleSet(@"攝氏度") .seriesSet( @[ AAObject(AASeriesElement) .nameSet(@"2017") .dataSet( @[ @[@97, @36, @79], @[@94, @74, @60], @[@68, @76, @58], @[@64, @87, @56], @[@68, @27, @73], @[@74, @99, @42], @[@7, @93, @87], @[@51, @69, @40], @[@38, @23, @33], @[@57, @86, @31] ]), AAObject(AASeriesElement) .nameSet(@"2018") .dataSet( @[ @[@25, @10, @87], @[@2, @75, @59], @[@11, @54, @8], @[@86, @55, @93], @[@5, @3, @58], @[@90, @63, @44], @[@91, @33, @17], @[@97, @3, @56], @[@15, @67, @48], @[@54, @25, @81] ]), AAObject(AASeriesElement) .nameSet(@"2019") .dataSet( @[ @[@47, @47, @21], @[@20, @12, @4], @[@6, @76, @91], @[@38, @30, @60], @[@57, @98, @64], @[@61, @17, @80], @[@83, @60, @13], @[@67, @78, @75], @[@64, @12, @10], @[@30, @77, @82] ]), ] ) ;
當(dāng)前已支持的圖表類型有十種以上,說(shuō)明如下
typedef NSString *AAChartType; static AAChartType const AAChartTypeColumn = @"column"; //柱形圖 static AAChartType const AAChartTypeBar = @"bar"; //條形圖 static AAChartType const AAChartTypeArea = @"area"; //折線區(qū)域填充圖 static AAChartType const AAChartTypeAreaspline = @"areaspline"; //曲線區(qū)域填充圖 static AAChartType const AAChartTypeLine = @"line"; //折線圖 static AAChartType const AAChartTypeSpline = @"spline"; //曲線圖 static AAChartType const AAChartTypeScatter = @"scatter"; //散點(diǎn)圖 static AAChartType const AAChartTypePie = @"pie"; //扇形圖 static AAChartType const AAChartTypeBubble = @"bubble"; //氣泡圖 static AAChartType const AAChartTypePyramid = @"pyramid"; //金字塔圖 static AAChartType const AAChartTypeFunnel = @"funnel"; //漏斗圖 static AAChartType const AAChartTypeColumnrange = @"columnrange";//柱形范圍圖
當(dāng)前已支持的圖表渲染動(dòng)畫類型有三十種以上,說(shuō)明如下
typedef NS_ENUM(NSInteger,AAChartAnimationType){ AAChartAnimationTypeLinear =0, AAChartAnimationTypeSwing, AAChartAnimationTypeEaseInQuad, AAChartAnimationTypeEaseOutQuad, AAChartAnimationTypeEaseInOutQuad, AAChartAnimationTypeEaseInCubic, AAChartAnimationTypeEaseOutCubic, AAChartAnimationTypeEaseInOutCubic, AAChartAnimationTypeEaseInQuart, AAChartAnimationTypeEaseOutQuart, AAChartAnimationTypeEaseInOutQuart, AAChartAnimationTypeEaseInQuint, AAChartAnimationTypeEaseOutQuint, AAChartAnimationTypeEaseInOutQuint, AAChartAnimationTypeEaseInExpo, AAChartAnimationTypeEaseOutExpo, AAChartAnimationTypeEaseInOutExpo, AAChartAnimationTypeEaseInSine, AAChartAnimationTypeEaseOutSine, AAChartAnimationTypeEaseInOutSine, AAChartAnimationTypeEaseInCirc, AAChartAnimationTypeEaseOutCirc, AAChartAnimationTypeEaseInOutCirc, AAChartAnimationTypeEaseInElastic, AAChartAnimationTypeEaseOutElastic, AAChartAnimationTypeEaseInOutElastic, AAChartAnimationTypeEaseInBack, AAChartAnimationTypeEaseOutBack, AAChartAnimationTypeEaseInOutBack, AAChartAnimationTypeEaseInBounce, AAChartAnimationTypeEaseOutBounce, AAChartAnimationTypeEaseInOutBounce, };AAChartModel一些重要屬性經(jīng)過(guò)配置之后的圖形示例如下 - line chart - 折線圖 - column chart - 柱形圖 - bar chart - 條形圖 - special area chart one - 區(qū)域填充圖一 - special area chart two - 區(qū)域填充圖二 - special area chart three - 區(qū)域填充圖三 - area spline range chart - 區(qū)域曲線范圍填充圖 - radar chart - 雷達(dá)圖 - polar chart - 極地圖 - pie chart - 扇形圖 - the oval style column chart - 頭部為橢圓形的柱形圖 - bubble chart - 氣泡圖 - mixed chart - 混合圖形 AAChartModel 屬性配置列表
AAPropStatementAndFuncStatement(copy, AAChartModel, NSString *, title);//標(biāo)題內(nèi)容 AAPropStatementAndFuncStatement(copy, AAChartModel, NSString *, subtitle);//副標(biāo)題內(nèi)容 AAPropStatementAndFuncStatement(copy, AAChartModel, AAChartSubtitleAlignType, subtitleAlign);//圖表副標(biāo)題文本水平對(duì)齊方式。可選的值有 “l(fā)eft”,”center“和“right”。 默認(rèn)是:center. AAPropStatementAndFuncStatement(copy, AAChartModel, AAChartType, chartType);//圖表類型 AAPropStatementAndFuncStatement(copy, AAChartModel, AAChartStackingType, stacking);//堆積樣式 AAPropStatementAndFuncStatement(copy, AAChartModel, AAChartSymbolType, symbol);//折線曲線連接點(diǎn)的類型:"circle", "square", "diamond", "triangle","triangle-down",默認(rèn)是"circle" AAPropStatementAndFuncStatement(copy, AAChartModel, AAChartZoomType, zoomType);//縮放類型 AAChartZoomTypeX表示可沿著 x 軸進(jìn)行手勢(shì)縮放 AAPropStatementAndFuncStatement(assign, AAChartModel, BOOL, pointHollow);//折線曲線的連接點(diǎn)是否為空心的 AAPropStatementAndFuncStatement(assign, AAChartModel, BOOL, inverted);//x 軸是否垂直 AAPropStatementAndFuncStatement(assign, AAChartModel, BOOL, xAxisReversed);// x 軸翻轉(zhuǎn) AAPropStatementAndFuncStatement(assign, AAChartModel, BOOL, yAxisReversed);//y 軸翻轉(zhuǎn) AAPropStatementAndFuncStatement(assign, AAChartModel, BOOL, crosshairs);//是否顯示準(zhǔn)星線(默認(rèn)顯示) AAPropStatementAndFuncStatement(assign, AAChartModel, BOOL, gradientColorEnable);//是否要為漸變色 AAPropStatementAndFuncStatement(assign, AAChartModel, BOOL, polar);//是否極化圖形(變?yōu)槔走_(dá)圖) AAPropStatementAndFuncStatement(assign, AAChartModel, BOOL, dataLabelEnabled);//是否顯示數(shù)據(jù) AAPropStatementAndFuncStatement(assign, AAChartModel, BOOL, xAxisLabelsEnabled);//x軸是否顯示數(shù)據(jù) AAPropStatementAndFuncStatement(strong, AAChartModel, NSArray *, categories);//圖表橫坐標(biāo)每個(gè)點(diǎn)對(duì)應(yīng)的名稱 AAPropStatementAndFuncStatement(strong, AAChartModel, NSNumber *, xAxisGridLineWidth);//x軸網(wǎng)格線的寬度 AAPropStatementAndFuncStatement(assign, AAChartModel, BOOL, yAxisLabelsEnabled);//y軸是否顯示數(shù)據(jù) AAPropStatementAndFuncStatement(copy, AAChartModel, NSString *, yAxisTitle);//y軸標(biāo)題 AAPropStatementAndFuncStatement(strong, AAChartModel, NSNumber *, yAxisGridLineWidth);//y軸網(wǎng)格線的寬度 AAPropStatementAndFuncStatement(strong, AAChartModel, NSArray *, colorsTheme);//圖表主題顏色數(shù)組 AAPropStatementAndFuncStatement(strong, AAChartModel, NSArray *, series); AAPropStatementAndFuncStatement(assign, AAChartModel, BOOL, legendEnabled);//是否顯示圖例 AAPropStatementAndFuncStatement(copy, AAChartModel ,AAChartLegendLayoutType, legendLayout);//圖例數(shù)據(jù)項(xiàng)的布局。布局類型: "horizontal" 或 "vertical" 即水平布局和垂直布局 默認(rèn)是:horizontal. AAPropStatementAndFuncStatement(copy, AAChartModel ,AAChartLegendAlignType, legendAlign);//設(shè)定圖例在圖表區(qū)中的水平對(duì)齊方式,合法值有l(wèi)eft,center 和 right。 AAPropStatementAndFuncStatement(copy, AAChartModel ,AAChartLegendVerticalAlignType, legendVerticalAlign);//設(shè)定圖例在圖表區(qū)中的垂直對(duì)齊方式,合法值有 top,middle 和 bottom。垂直位置可以通過(guò) y 選項(xiàng)做進(jìn)一步設(shè)定。 AAPropStatementAndFuncStatement(copy, AAChartModel, NSString *, backgroundColor);//圖表背景色 AAPropStatementAndFuncStatement(assign, AAChartModel, BOOL, options3dEnable);//是否3D化圖形(僅對(duì)條形圖,柱狀圖有效) AAPropStatementAndFuncStatement(strong, AAChartModel, NSNumber *, options3dAlpha); AAPropStatementAndFuncStatement(strong, AAChartModel, NSNumber *, options3dBeta); AAPropStatementAndFuncStatement(strong, AAChartModel, NSNumber *, options3dDepth);//3D圖形深度 AAPropStatementAndFuncStatement(strong, AAChartModel, NSNumber *, borderRadius);//柱狀圖長(zhǎng)條圖頭部圓角半徑(可用于設(shè)置頭部的形狀,僅對(duì)條形圖,柱狀圖有效) AAPropStatementAndFuncStatement(strong, AAChartModel, NSNumber *, markerRadius);//折線連接點(diǎn)的半徑長(zhǎng)度更多圖形效果 支持監(jiān)聽(tīng)用戶點(diǎn)擊事件及單指滑動(dòng)事件
可通過(guò)給 AAChartView 示例對(duì)象設(shè)置代理方法,來(lái)實(shí)現(xiàn)監(jiān)聽(tīng)用戶的點(diǎn)擊事件和單指滑動(dòng)事件
//設(shè)置 AAChartView 事件代理 self.aaChartView.delegate = self; //實(shí)現(xiàn)對(duì) AAChartView 事件代理的監(jiān)聽(tīng) #pragma mark -- AAChartView delegate - (void)AAChartView:(AAChartView *)chartView moveOverEventWithMessage:(AAMoveOverEventMessageModel *)message { NSLog(@"
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://m.specialneedsforspecialkids.com/yun/82396.html
摘要:可選的值有,和。布局類型或即水平布局和垂直布局默認(rèn)是設(shè)定圖例在圖表區(qū)中的水平對(duì)齊方式,合法值有,和。垂直位置可以通過(guò)選項(xiàng)做進(jìn)一步設(shè)定。 showImg(https://segmentfault.com/img/remote/1460000012009745?w=1240&h=653); showImg(https://segmentfault.com/img/remote/146000...
摘要:也是一款優(yōu)秀的響應(yīng)式框架站點(diǎn)所使用的一套框架為微信服務(wù)量身設(shè)計(jì)的一套框架一組很小的,響應(yīng)式的組件,你可以在網(wǎng)頁(yè)的項(xiàng)目上到處使用一個(gè)可定制的文件,使瀏覽器呈現(xiàn)的所有元素,更一致和符合現(xiàn)代標(biāo)準(zhǔn)。 GitHub 值得收藏的前端項(xiàng)目 整理與收集的一些比較優(yōu)秀github項(xiàng)目,方便自己閱讀,順便分享出來(lái),大家一起學(xué)習(xí),本篇文章會(huì)持續(xù)更新,版權(quán)歸原作者所有。歡迎github star與fork 預(yù)...
閱讀 1631·2021-11-16 11:45
閱讀 2560·2021-09-29 09:48
閱讀 3339·2021-09-07 10:26
閱讀 1853·2021-08-16 10:50
閱讀 1884·2019-08-30 15:44
閱讀 2710·2019-08-28 18:03
閱讀 1909·2019-08-27 10:54
閱讀 1835·2019-08-26 14:01