core-plot barchart does not work!!

Posted by user355068 on Stack Overflow See other posts from Stack Overflow or by user355068
Published on 2010-06-01T04:59:21Z Indexed on 2010/06/01 5:03 UTC
Read the original article Hit count: 309

Filed under:
|

Hello~

I try to draw bar chart!!

numberForPlot is not good work, only CPBarPlotFieldBarLength set.

-(NSNumber *)numberForPlot: (CPPlot *)plot field:(NSUInteger)fieldEnum  recordIndex:(NSUInteger)index {
    NSDecimalNumber *num = nil;
    NSString *key = (fieldEnum == CPScatterPlotFieldX) ? @"x" : @"y";
    if ( [plot isKindOfClass:[CPBarPlot class]] ) {
        switch ( fieldEnum ) {
            NSLog(@"fieldEnum = %d",fieldEnum);
            case CPBarPlotFieldBarLocation:
                num = (NSDecimalNumber *)[NSDecimalNumber numberWithUnsignedInteger:index];
                NSLog(@"CPBarPlotFieldBarLocation return num = %@",num);
                break;
            case CPBarPlotFieldBarLength:
                num = (NSDecimalNumber *)[NSDecimalNumber numberWithUnsignedInteger:    (index+1)*(index+1)];
                if ( [plot.identifier isEqual:Plot3Identity] )
                num = [[self.ExForPlot objectAtIndex:index] valueForKey:key];
                NSLog(@"CPBarPlotFieldBarLength return num = %@",num);
                break;
        }
    }
    else {
        NSLog(@"...??..");
    }
    return num;
}

# LOG
2010-06-01 02:43:19.424 myHealth[5071:207] CPBarPlotFieldBarLength return num = 0
2010-06-01 02:43:19.425 myHealth[5071:207] CPBarPlotFieldBarLength return num = 0
2010-06-01 02:43:19.425 myHealth[5071:207] CPBarPlotFieldBarLength return num = 30



# EXPlot set
    // Add some initial data
    NSMutableArray *contentArray = [NSMutableArray arrayWithCapacity:100];
    int prevWeight = 0;
    int prevBmi = 0 ;
    if (sqlite3_prepare_v2(database, sql, -1, &statement, NULL) == SQLITE_OK) {
    while (sqlite3_step(statement)==SQLITE_ROW) {
        id x = [NSNumber numberWithInt:graphTimeStamp];                                                
        id y = [NSNumber numberWithInt:sqlite3_column_int(statement, 2)];
        [contentArray addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:x, @"x", y, @"y", nil]];
    }
    self.ExForPlot = contentArray;

© Stack Overflow or respective owner

Related posts about core-plot

Related posts about objective-c-2.0