Skip to content

mengzhiqc/BarChart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BarChart

A UIView For Draw Bar Chart

How To Install

If you havn't used cocoapods, please visit [http://cocoapods.org/] to learn the basic usage.

  • step1. execute pod init in your command line and open your Podfile
  • step2. add pod 'DBBarChart',:git=>'https://github.com/mengzhiqc/BarChart.git' in your Podfile
  • step3. execute pod install

How To Use

  • import the header file

    #import "DBBarChartView.h"
  • prepare the data to be displayed

    eg.

    NSArray *itemData = @[
                          @{@"itemName":@"Flower",@"value":@"5"},
                          @{@"itemName":@"Book",@"value":@"6"},
                          @{@"itemName":@"Bus",@"value":@"8"},
                          @{@"itemName":@"Others",@"value":@"2"},
                          ];
  • init barChartView and set delegate to current view controller
    DBBarChartView *barChartView = [[DBBarChartView alloc]initWithData:itemData frame:CGRectMake(0, 20, 280, 100)];
    barChartView.delegate = self;

please don't forget to add BarChartViewDelegate in your header file.

  • add this view as subview
    [self.view addSubview:barChartView];
  • result as follow

Alt Result

  • we have provided some delegate so that you can change color and some other properties of chart view
    - (UIColor *)barColorOfChartView:(DBBarChartView *)barChartView ;
    - (UIColor *)labelColorOfChartView:(DBBarChartView *)barChartView ;
    - (UIColor *)numberLabelcolorOfChartView:(DBBarChartView *)barChartView ;
    - (CGFloat)widthOfBarCharView:(DBBarChartView *)charView;

About

A UIView For Draw Bar Chart

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published