1 Star 1 Fork 0

zhanggm79 / AAChartKit

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 25.65 KB
一键复制 编辑 原始数据 按行查看 历史

AAChartKit-LOGO

AAChartKit

Support







English Document 🇬🇧 | 简体中文文档 🇨🇳 | 繁體中文文檔 🇭🇰

The Swift version of AAChartKit can be found here:

https://github.com/AAChartModel/AAChartKit-Swift

Preface

AAChartKit is an elegant, friendly and easy to use chart library for iOS, based on the open source Highcharts JS libraries. AAChartKit is extremely powerful, easy to configure and a pleasure to use. Currently AAChartKit includes support for the following chart types: column chart, bar chart, area chart, area spline chart, line chart, spline chart, radar chart, polar chart, pie chart, bubble chart, pyramid chart, funnel chart, column range and area range chart. More chart types are planned to be supported. AAChartKit gives you easy and fast access to a wide range of chart types, hassle free and quickly to integrate into your own project.


Features

  1. Support up from iOS 6, ARC support.
  2. Powerful and easy to use. It supports the column chart, bar chart, area chart, areaspline chart, line chart, spline chart, radar chart, polar chart, pie chart, bubble chart, pyramid chart, funnel chart, columnrange chart, arearange chart and mixed chart and other graphics. Support for more chart types is planned.
  3. The charts are interactive and animated. The animation effect is exquisite, delicate, smooth and beautiful.
  4. Supports chain programming syntax like Masonry
  5. AAChartView + AAChartModel = Chart. The AAChartKit follows a minimalist formula: Chart view + Chart model = The chart you want. Just like the powerful and beautiful charts lib AAInfographics

Beauty Appreciation

Column Chart Column Range Chart Area Chart
image1 image1 image1
Line Chart Step Area Chart Step Line Chart
image1 image1 image1
Spline Chart Areaspline Chart Stacked Polar Chart
image1 image1 image1

Usage

The required 'pre' work

  1. Drag the AAChartKitLib folder into your project.

  2. Add the following to your .pch file.

#import "AAGlobalMacro.h"

The 'real' work

  1. Add the following to your view controller file:
#import "AAChartView.h"
  1. Creat an instance object of chart view:AAChartView
CGFloat chartViewWidth  = self.view.frame.size.width;
CGFloat chartViewHeight = self.view.frame.size.height-250;
_aaChartView = [[AAChartView alloc]init];
_aaChartView.frame = CGRectMake(0, 60, chartViewWidth, chartViewHeight);
//_aaChartView.scrollEnabled = NO;
//// set the content height of aaChartView
// _aaChartView.contentHeight = chartViewHeight;
[self.view addSubview:_aaChartView];
  1. Configure the chart model properties: AAChartModel
AAChartModel *aaChartModel= AAObject(AAChartModel)
.chartTypeSet(AAChartTypeColumn)
.titleSet(@"THE HEAT OF PROGRAMMING LANGUAGE")
.subtitleSet(@"Virtual Data")
.categoriesSet(@[@"Java",@"Swift",@"Python",@"Ruby", @"PHP",@"Go",@"C",@"C#",@"C++"])
.yAxisTitleSet(@"Degrees Celsius")
.seriesSet(@[
        AAObject(AASeriesElement)
        .nameSet(@"2017")
        .dataSet(@[@7.0, @6.9, @9.5, @14.5, @18.2, @21.5, @25.2, @26.5, @23.3, @18.3, @13.9, @9.6]),
        AAObject(AASeriesElement)
        .nameSet(@"2018")
        .dataSet(@[@0.2, @0.8, @5.7, @11.3, @17.0, @22.0, @24.8, @24.1, @20.1, @14.1, @8.6, @2.5]),
        AAObject(AASeriesElement)
        .nameSet(@"2019")
        .dataSet(@[@0.9, @0.6, @3.5, @8.4, @13.5, @17.0, @18.6, @17.9, @14.3, @9.0, @3.9, @1.0]),
        AAObject(AASeriesElement)
        .nameSet(@"2020")
        .dataSet(@[@3.9, @4.2, @5.7, @8.5, @11.9, @15.2, @17.0, @16.6, @14.2, @10.3, @6.6, @4.8]),
                 ])
;
  1. Draw the chart (this method is called only for the first time after you create an AAChartView instance object)
//The chart view object calls the instance object of AAChartModel and draws the final graphic
[_aaChartView aa_drawChartWithChartModel:aaChartModel];
  1. Refresh the chart data only (this method is recommended to be called for updating the series data dynamically)
//Refresh the chart dynamically only when the series attribute of the AAChartModel object is updated
[_aaChartView aa_onlyRefreshTheChartDataWithChartModelSeries:aaChartModelSeriesArray];
  1. Refresh the chart except the chart data (subsequent refresh options are recommended to call this method after the first drawing of graphics has completed.if you want to update the chart data only,you should use the function aa_onlyRefreshTheChartDataWithChartModelSeries)
//Refresh the chart after the AAChartModel content is updated
[_aaChartView aa_refreshChartWithChartModel:aaChartModel];

Samples

  • line chart

IMG_1867.JPG

  • column chart

IMG_1873.JPG

  •  bar chart

IMG_1880.JPG

  • special area chart one

IMG_1869.JPG

  • special area chart two

IMG_1871.JPG

  • special area chart three

IMG_1863.JPG

  • radar chart

IMG_1877.JPG

  • polar chart

IMG_1879.JPG

  • pie chart

IMG_1878.JPG

  • bubble chart

IMG_1875.JPG

  • scatter chart

scatter chart

  • arearange chart

arearange chart

  • step area chart

step area chart

  • mixed chart

mixed chart

More graphics

  • Note: The following DEMO picture is a GIF dynamic picture which has a size of around 6M. If you don't see any dynamic preview, then this is because the picture resources were not fully loaded. In such a case please be patient and wait for the contents to finish loading. Maybe you need to reload this page.

image

Special instructions

Special chart types in AAChartKit

The pie chart as well as the bubble chart are special in AAChartKit. If you want to draw these types of charts, then you need to prepare the AAChartModel differently:

  • To draw a pie chart, you should configure the properties of AAChartModel like this:
   AAChartModel *chartModel= AAObject(AAChartModel)
    .chartTypeSet(AAChartTypePie)
    .titleSet(@"THE HEAT OF PROGRAMMING LANGUAGE")
    .subtitleSet(@"Virtual Data")
    .yAxisTitleSet(@"Degrees Celsius")
    .seriesSet(
               @[AAObject(AASeriesElement)
                 .nameSet(@"Percent")
                 .dataSet(@[
                            @[@"Java"  , @67],
                            @[@"Swift" , @44],
                            @[@"Python", @83],
                            @[@"OC"    , @11],
                            @[@"Ruby"  , @42],
                            @[@"PHP"   , @31],
                            @[@"Go"    , @63],
                            @[@"C"     , @24],
                            @[@"C#"    , @888],
                            @[@"C++"   , @66],
                            ]),
                 ]
               
               )
    ;
  • To draw a bubble chart, you should configure the properties of AAChartModel like this:
   AAChartModel *chartModel= AAObject(AAChartModel)
    .chartTypeSet(AAChartTypeBubble)
    .titleSet(@"THE HEAT OF PROGRAMMING LANGUAGE")
    .subtitleSet(@"Virtual Data")
    .yAxisTitleSet(@"Degrees Celsius")
    .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]
                            ]),
                 
                 ]
               )
    ;

Supported chart types for now

typedef NSString *AAChartType;

UIKIT_EXTERN AAChartType const AAChartTypeColumn;      //column chart
UIKIT_EXTERN AAChartType const AAChartTypeBar;         //bar chart
UIKIT_EXTERN AAChartType const AAChartTypeArea;        //area chart
UIKIT_EXTERN AAChartType const AAChartTypeAreaspline;  //areaspline chart
UIKIT_EXTERN AAChartType const AAChartTypeLine;        //line chart
UIKIT_EXTERN AAChartType const AAChartTypeSpline;      //spline chart
UIKIT_EXTERN AAChartType const AAChartTypeScatter;     //scatter chart
UIKIT_EXTERN AAChartType const AAChartTypePie;         //pie chart
UIKIT_EXTERN AAChartType const AAChartTypeBubble;      //bubble chart
UIKIT_EXTERN AAChartType const AAChartTypePyramid;     //pyramid chart
UIKIT_EXTERN AAChartType const AAChartTypeFunnel;      //funnel chart
UIKIT_EXTERN AAChartType const AAChartTypeColumnrange; //columnrange chart
UIKIT_EXTERN AAChartType const AAChartTypeArearange;   //arearange chart

Supported zoom guesture types for now

typedef NSString *AAChartZoomType;

UIKIT_EXTERN AAChartZoomType const AAChartZoomTypeNone;
UIKIT_EXTERN AAChartZoomType const AAChartZoomTypeX;
UIKIT_EXTERN AAChartZoomType const AAChartZoomTypeY;
UIKIT_EXTERN AAChartZoomType const AAChartZoomTypeXY;

Supported animation types for now

typedef NS_ENUM(NSInteger,AAChartAnimation) {
    AAChartAnimationLinear = 0,
    AAChartAnimationEaseInQuad,
    AAChartAnimationEaseOutQuad,
    AAChartAnimationEaseInOutQuad,
    AAChartAnimationEaseInCubic,
    AAChartAnimationEaseOutCubic,
    AAChartAnimationEaseInOutCubic,
    AAChartAnimationEaseInQuart,
    AAChartAnimationEaseOutQuart,
    AAChartAnimationEaseInOutQuart,
    AAChartAnimationEaseInQuint,
    AAChartAnimationEaseOutQuint,
    AAChartAnimationEaseInOutQuint,
    AAChartAnimationEaseInSine,
    AAChartAnimationEaseOutSine,
    AAChartAnimationEaseInOutSine,
    AAChartAnimationEaseInExpo,
    AAChartAnimationEaseOutExpo,
    AAChartAnimationEaseInOutExpo,
    AAChartAnimationEaseInCirc,
    AAChartAnimationEaseOutCirc,
    AAChartAnimationEaseInOutCirc,
    AAChartAnimationEaseOutBounce,
    AAChartAnimationEaseInBack,
    AAChartAnimationEaseOutBack,
    AAChartAnimationEaseInOutBack,
    AAChartAnimationElastic,
    AAChartAnimationSwingFromTo,
    AAChartAnimationSwingFrom,
    AAChartAnimationSwingTo,
    AAChartAnimationBounce,
    AAChartAnimationBouncePast,
    AAChartAnimationEaseFromTo,
    AAChartAnimationEaseFrom,
    AAChartAnimationEaseTo,
};

AAChartModel:chart attribute list

AAPropStatementAndFuncStatement(copy,   AAChartModel, NSString *, title);
AAPropStatementAndFuncStatement(copy,   AAChartModel, NSNumber *, titleFontSize);
AAPropStatementAndFuncStatement(copy,   AAChartModel, NSString *, titleFontColor);
AAPropStatementAndFuncStatement(copy,   AAChartModel, NSString *, titleFontWeight);

AAPropStatementAndFuncStatement(copy,   AAChartModel, NSString *, subtitle);
AAPropStatementAndFuncStatement(copy,   AAChartModel, NSNumber *, subtitleFontSize);
AAPropStatementAndFuncStatement(copy,   AAChartModel, NSString *, subtitleFontColor);
AAPropStatementAndFuncStatement(copy,   AAChartModel, NSString *, subtitleFontWeight);

AAPropStatementAndFuncStatement(strong, AAChartModel, NSArray  *, series);
AAPropStatementAndFuncStatement(strong, AAChartModel, NSArray *,  keys); 

AAPropStatementAndFuncStatement(copy,   AAChartModel, AAChartSubtitleAlignType, subtitleAlign);
AAPropStatementAndFuncStatement(copy,   AAChartModel, AAChartType,              chartType);
AAPropStatementAndFuncStatement(copy,   AAChartModel, AAChartStackingType,      stacking);
AAPropStatementAndFuncStatement(copy,   AAChartModel, AAChartSymbolType,        symbol);
AAPropStatementAndFuncStatement(assign, AAChartModel, AAChartSymbolStyleType,   symbolStyle);
AAPropStatementAndFuncStatement(copy,   AAChartModel, AAChartZoomType,          zoomType);
AAPropStatementAndFuncStatement(assign, AAChartModel, AAChartAnimation,         animationType);

AAPropStatementAndFuncStatement(strong, AAChartModel, NSNumber *, animationDuration);
AAPropStatementAndFuncStatement(assign, AAChartModel, BOOL,       inverted);
AAPropStatementAndFuncStatement(assign, AAChartModel, BOOL,       xAxisReversed);
AAPropStatementAndFuncStatement(assign, AAChartModel, BOOL,       yAxisReversed);
AAPropStatementAndFuncStatement(assign, AAChartModel, BOOL,       gradientColorEnabled);
AAPropStatementAndFuncStatement(assign, AAChartModel, BOOL,       polar);
AAPropStatementAndFuncStatement(assign, AAChartModel, BOOL,       dataLabelEnabled);
AAPropStatementAndFuncStatement(copy,   AAChartModel, NSString *, dataLabelFontColor);
AAPropStatementAndFuncStatement(strong, AAChartModel, NSNumber *, dataLabelFontSize);
AAPropStatementAndFuncStatement(copy,   AAChartModel, NSString *, dataLabelFontWeight);
AAPropStatementAndFuncStatement(assign, AAChartModel, BOOL,       xAxisLabelsEnabled);
AAPropStatementAndFuncStatement(copy,   AAChartModel, NSNumber *, xAxisLabelsFontSize);
AAPropStatementAndFuncStatement(copy,   AAChartModel, NSString *, xAxisLabelsFontColor);
AAPropStatementAndFuncStatement(copy,   AAChartModel, NSString *, xAxisLabelsFontWeight);
AAPropStatementAndFuncStatement(strong, AAChartModel, NSArray  *, categories);
AAPropStatementAndFuncStatement(strong, AAChartModel, NSNumber *, xAxisGridLineWidth);
AAPropStatementAndFuncStatement(strong, AAChartModel, NSNumber *, xAxisTickInterval);

AAPropStatementAndFuncStatement(assign, AAChartModel, BOOL,       xAxisVisible);
AAPropStatementAndFuncStatement(assign, AAChartModel, BOOL,       yAxisVisible);
AAPropStatementAndFuncStatement(assign, AAChartModel, BOOL,       yAxisLabelsEnabled);
AAPropStatementAndFuncStatement(copy,   AAChartModel, NSString *, yAxisTitle);
AAPropStatementAndFuncStatement(copy,   AAChartModel, NSNumber *, yAxisLabelsFontSize);
AAPropStatementAndFuncStatement(copy,   AAChartModel, NSString *, yAxisLabelsFontColor);
AAPropStatementAndFuncStatement(copy,   AAChartModel, NSString *, yAxisLabelsFontWeight);
AAPropStatementAndFuncStatement(strong, AAChartModel, NSNumber *, yAxisGridLineWidth);
AAPropStatementAndFuncStatement(strong, AAChartModel, NSArray     <NSString *>*, colorsTheme);
AAPropStatementAndFuncStatement(copy,   AAChartModel, NSString *, backgroundColor);

AAPropStatementAndFuncStatement(assign, AAChartModel, BOOL,       tooltipEnabled);
AAPropStatementAndFuncStatement(copy,   AAChartModel, NSString *, tooltipValueSuffix);
AAPropStatementAndFuncStatement(copy  , AAChartModel, NSString *, tooltipValueString);
AAPropStatementAndFuncStatement(assign, AAChartModel, BOOL,       tooltipCrosshairs);
AAPropStatementAndFuncStatement(assign, AAChartModel, BOOL,       connectNulls);
AAPropStatementAndFuncStatement(assign, AAChartModel, BOOL,       legendEnabled);

AAPropStatementAndFuncStatement(assign, AAChartModel, BOOL,       options3dEnabled);
AAPropStatementAndFuncStatement(strong, AAChartModel, NSNumber *, options3dAlpha);
AAPropStatementAndFuncStatement(strong, AAChartModel, NSNumber *, options3dBeta);
AAPropStatementAndFuncStatement(strong, AAChartModel, NSNumber *, options3dDepth);

AAPropStatementAndFuncStatement(strong, AAChartModel, NSNumber *, borderRadius);
AAPropStatementAndFuncStatement(strong, AAChartModel, NSNumber *, markerRadius);

AAPropStatementAndFuncStatement(assign, AAChartModel, BOOL,       yAxisAllowDecimals);
AAPropStatementAndFuncStatement(strong, AAChartModel, NSArray  *, yAxisPlotLines);
AAPropStatementAndFuncStatement(strong, AAChartModel, NSNumber *, yAxisMax);
AAPropStatementAndFuncStatement(strong, AAChartModel, NSNumber *, yAxisMin);
AAPropStatementAndFuncStatement(strong, AAChartModel, NSArray  *, yAxisTickPositions);
AAPropStatementAndFuncStatement(copy,   AAChartModel, NSString *, zoomResetButtonText);

Created By:

An An

                         _0_
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                    ___/`---'\___
                  .' \\|     |// '.
                 / \\|||  :  |||// \
                / _||||| -:- |||||- \
               |   | \\\  -  /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
             ___'. .'  /--.--\  `. .'___
          ."" '<  `.___\_<|>_/___.' >' "".
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
     =====`-.____`.___ \_____/___.-`___.-'=====
                       `=---='
*****************************************************
     ¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥
         €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
               $$$$$$$$$$$$$$$$$$$$$$$  
                   BUDDHA_BLESS_YOU       
                      AWAY_FROM
                         BUG

Source Code⛓

Language Version Project Name Source Code Link
Objective C AAChartKit https://github.com/AAChartModel/AAChartKit
Swift AAInfographics https://github.com/AAChartModel/AAChartKit-Swift

LICENSE

AAChartKit is available under the MIT license. See the LICENSE file for more information.

Contact




Postscript

If you want to shrink the size of the AAChartKit lib, you should do something like this:

  1. Delete the .js file of AAJSFiles folder in AAChartKit. The names of the files that need to be deleted are the following:
  • AAHighchartsLib.js
  • AAHighchartsMore.js
  • AAHighcharts-3d.js
  • AAFunnel.js

2.Change the content of AAChartView.html file

<script src="AAHighchartsLib.js">
</script>
<script src="AAHighchartsMore.js">
</script>
<script src="AAHighcharts-3d.js">
</script>
<script src="AAFunnel.js">
</script>

to be

<script src="https://img.hcharts.cn/highcharts/highcharts.js">
</script>
<script src="https://img.hcharts.cn/highcharts/highcharts-more.js">
</script>

To-Do list

    • Support user to add delegate events after the graphics content loading was completed
    • Support graphics to refresh global content dynamically
    • Support graphics to refresh pure data (series) content dynamically
    • Support graphics to refresh pure data in real time and scroll dynamically
    • Support color layer gradient effects
    • Support 3D graphics effects, valid only for partial graphics such as column chart、bar chart、pie charts、scatterplot chart、bubble chart, etc.
    • Support CocoaPods
    • Support Carthage
    • Support code coverage test
    • Support horizontal screen (full screen) effect
    • Support setting graphics rendering animation freely
    • Support rendered graphics to generate image files
    • Support generating image files saved to the system album
    • Support user to configure AAOptions model object properties freely
    • Support stacking the graphics
    • Support reversing the graphics axis
    • Support rendering scatter chart
    • Support rendering column range map
    • Support rendering area range graph
    • Support rendering the polar chart
    • Support rendering the step line chart
    • Support rendering the step area chart
    • Support rendering the Nightingale rose 🌹chart
    • Support rendering the rectangular tree hierarchy diagrams
    • Support rendering the circular progress bar chart
    • Support adding clicked event callbacks for graphics
Objective-C
1
https://gitee.com/7900/AAChartKit.git
git@gitee.com:7900/AAChartKit.git
7900
AAChartKit
AAChartKit
master

搜索帮助