WHChartView 1.1.2

WHChartView 1.1.2

测试已测试
Lang语言 Obj-CObjective C
许可协议 MIT
发布最后发布2015年9月

wongkoo 维护。



  • 作者:
  • wongkoo

GIF

screen{

用法

初始化

WHChartView *chart = [[WHChartView alloc]initWithFrame:(CGRect)rect];

必需

- (void)setChartData:(NSArray *)chartData;
- (void)strokeChart;

可选

/***  Coordinate ***/
@property (nonatomic, strong)   NSString *title;
@property (nonatomic, strong)   UIColor *colorOfTitle;
@property (nonatomic, strong)   UIColor *colorOfXYLabel;
@property (nonatomic, strong)   UIColor *colorOfAxis;
@property (nonatomic, strong)   UIColor *colorOfGridding;
@property (nonatomic)           BOOL showsGridding;
@property (nonatomic)           BOOL showsXLabel;
@property (nonatomic, strong)   NSArray *xLabelString;  //Data of XLabel


/***  Bar in Chart ***/
@property (nonatomic)           BOOL drawsBarChart;
@property (nonatomic, strong)   UIColor *colorOfBar;
@property (nonatomic, strong)   UIColor *colorOfUnusedPartOfBar;
@property (nonatomic)           BOOL showsShadowOfBar;
@property (nonatomic, strong)   UIColor *colorOfShadow;
@property (nonatomic)           double angleOfShadow;
@property (nonatomic)           CFTimeInterval animationDurationOfBar; //animationDuration


/***  Line in Chart ***/
@property (nonatomic)           BOOL drawsLineChart;
@property (nonatomic)           CGFloat lineWidth;
@property (nonatomic, strong)   UIColor *colorOfLine;
@property (nonatomic)           CFTimeInterval animationDurationOfLine;

@property (nonatomic)           BOOL smoothesLine;        //BazierPath
@property (nonatomic)           CGFloat kOfBezierPath;

@property (nonatomic)           BOOL showsGradientColor; //GradientColor
@property (nonatomic, strong)   NSArray *gradientColors;
@property (nonatomic, strong)   NSArray *gradientLocations;
@property (nonatomic)           CGPoint gradientStartPoint;
@property (nonatomic)           CGPoint gradientEndPoint;

示例

    WHChartView *chart = [[WHChartView alloc]initWithFrame:CGRectMake(20, 50, self.view.bounds.size.width - 40, 200)];

    NSArray *dataValue = @[@123.5,@122,@87,@101.1,@16,@60.6,@51,@44,@20,@18,@98,@110,@19,@77];
    NSArray *xLabelString = @[@"6-10",@"6-11",@"6-12",@"6-13",@"6-14",@"6-15",@"6-16",@"6-17",@"6-12",@"6-13",@"6-14",@"6-15",@"6-16",@"6-17"];

    /***  Coordinate ***/
    chart.title = @"Bar and Line";
    //chart.colorOfTitle = [UIColor whClouds];              //Using default value;
    //chart.colorOfXYLabel = [UIColor lightGrayColor];      //Using default value;
    //chart.colorOfAxis = [UIColor whClouds];               //Using default value;
    //chart.colorOfGridding = [UIColor whClouds];           //Using default value;
    chart.showsGridding = YES;
    chart.showsXLabel = YES;
    chart.xLabelString = xLabelString;

    /***  Bar in Chart ***/
    chart.drawsBarChart = YES;
    chart.colorOfBar = [UIColor whAsbestos];
    chart.colorOfUnusedPartOfBar = [UIColor clearColor];
    chart.showsShadowOfBar = NO;
    //chart.colorOfShadow = [UIColor colorWithRed:0.35 green:0.45 blue:0.55 alpha:0.9];
    //chart.angleOfShadow = 30.0;
    //chart.animationDurationOfBar = 1.5;                   //Using default value;

    /***  Line in Chart ***/
    chart.drawsLineChart = YES;
    //chart.lineWidth = 1.0;                                //Using default value;
    //chart.colorOfLine = [UIColor blackColor];
    //chart.animationDurationOfLine = 1.5;                  //Using default value;

    chart.smoothesLine = YES;
    //chart.kOfBezierPath = 0.25;                           //Using default value;
    chart.showsGradientColor = YES;
    //chart.gradientColors = [NSArray arrayWithObjects:(id)[UIColor whGreen].CGColor ,(id)[UIColor whOrange].CGColor,(id)[UIColor whAlizarin].CGColor, nil];                            //Using default value;
    //chart.gradientLocations = @[@0.2,@0.5,@0.9 ];         //Using default value;
    //chart.gradientStartPoint = CGPointMake(0.5, 0);       //Using default value;
    //chart.gradientEndPoint = CGPointMake(0.5, 1);         //Using default value;


    [chart setChartData:dataValue];
    [chart strokeChart];

    [self.view addSubview:chart];

许可证

WHChartView 依据 MIT 许可协议提供。有关更多信息,请参阅 LICENSE 文件。