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;