Giter VIP home page Giter VIP logo

uuchartview's Introduction

UUChartView

Line and Bar charts. You can mark the range of values you want, and show the max or min values in linechart.

Flipboard playing multiple GIFs

Introduction

  • UUChart
  • UULineChart
  • UUBarChart
  • UUColor
  • UUBar

Usage

init

-(id)initwithUUChartDataFrame:(CGRect)rect 
                   withSource:(id<UUChartDataSource>)dataSource 
                    withStyle:(UUChartStyle)style;

Select from two styles for UUChartView:

UUChartLineStyle
UUChartBarStyle

UUChartDataSource

####required

- (NSArray *)UUChart_xLableArray:(UUChart *)chart;
//The target array's object's class is equal to NSArray
- (NSArray *)UUChart_yValueArray:(UUChart *)chart;

####optional

// the colors for lines and bars.
- (NSArray *)UUChart_ColorArray:(UUChart *)chart;
//CGRange CGRangeMake(CGFloat max, CGFloat min);
- (CGRange)UUChartChooseRangeInLineChart:(UUChart *)chart;

####Additional options available for UUChartLineStyle

//Mark the range of values with grayColor if you need
- (CGRange)UUChartMarkRangeInLineChart:(UUChart *)chart;

//You can choose horizonLine which you want to show
- (BOOL)UUChart:(UUChart *)chart ShowHorizonLineAtIndex:(NSInteger)index;

// Show the label on the max and min values with their colors.
- (BOOL)UUChart:(UUChart *)chart ShowMaxMinAtIndex:(NSInteger)index;

UUChart, based on kevinzhow's PNChart, was created on 2014-7-24, although UUChart is now very different from PNChart.

Demo

chartView = [[UUChart alloc]initwithUUChartDataFrame:CGRectMake(10, 10, [UIScreen mainScreen].bounds.size.width-20, 150)
                                          withSource:self
                                           withStyle:indexPath.section==1?UUChartBarStyle:UUChartLineStyle];
[chartView showInView:self.contentView];

//Horizontal Axis Label

- (NSArray *)UUChart_xLableArray:(UUChart *)chart
{
    if (path.section==0) {
        switch (path.row) {
            case 0:
                return [self getXTitles:5];
            case 1:
                return [self getXTitles:11];
            case 2:
                return [self getXTitles:7];
            case 3:
                return [self getXTitles:7];
            default:
                break;
        }
    }else{
        switch (path.row) {
            case 0:
                return [self getXTitles:11];
            case 1:
                return [self getXTitles:7];
            default:
                break;
        }
    }
    return [self getXTitles:20];
}
- (NSArray *)getXTitles:(int)num
{
    NSMutableArray *xTitles = [NSMutableArray array];
    for (int i=0; i<num; i++) {
        NSString * str = [NSString stringWithFormat:@"R-%d",i];
        [xTitles addObject:str];
    }
    return xTitles;
}	

//Creating multiple array values (note the datatype)

- (NSArray *)UUChart_yValueArray:(UUChart *)chart
{
    NSArray *ary = @[@"22",@"44",@"15",@"40",@"42"];
    NSArray *ary1 = @[@"22",@"54",@"15",@"30",@"42",@"77",@"43"];
    NSArray *ary2 = @[@"76",@"34",@"54",@"23",@"16",@"32",@"17"];
    NSArray *ary3 = @[@"3",@"12",@"25",@"55",@"52"];
    NSArray *ary4 = @[@"23",@"42",@"25",@"15",@"30",@"42",@"32",@"40",@"42",@"25",@"33"];

    if (path.section==0) {
        switch (path.row) {
            case 0:
                return @[ary];
            case 1:
                return @[ary4];
            case 2:
                return @[ary1,ary2];
            default:
                return @[ary1,ary2,ary3];
        }
    }else{
        if (path.row) {
            return @[ary1,ary2];
        }else{
            return @[ary4];
        }
    }
}

//Array of colors

- (NSArray *)UUChart_ColorArray:(UUChart *)chart
{
    return @[UUGreen,UURed,UUBrown];
}

//Choose line chart range

- (CGRange)UUChartChooseRangeInLineChart:(UUChart *)chart
{
    if (path.section==0 && (path.row==0|path.row==1)) {
        return CGRangeMake(60, 10);
    }
    if (path.section==1 && path.row==0) {
        return CGRangeMake(60, 10);
    }
    if (path.row==2) {
        return CGRangeMake(100, 0);
    }
    return CGRangeZero;
}

Features only available for line charts

//Ability to declare line chart range

- (CGRange)UUChartMarkRangeInLineChart:(UUChart *)chart
{
   if (path.row==2) {
       return CGRangeMake(25, 75);
    }
  return CGRangeZero;
}

//Display horizontal line

- (BOOL)UUChart:(UUChart *)chart ShowHorizonLineAtIndex:(NSInteger)index
{
    return YES;
}

//Determine the minimum and maximum display

- (BOOL)UUChart:(UUChart *)chart ShowMaxMinAtIndex:(NSInteger)index
{
    return path.row==2;
}

uuchartview's People

Contributors

zhipingyang avatar cornelisonc avatar rolandasrazma avatar

Watchers

Abhishek Sheth avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.