何時間も投資した後、何が欠けているのかわかりません。カスタム ラベルに関連する多くの例をたどりましたが、答えが見つかりません。何が間違っている可能性がありますか?よろしくお願いいたします。
カスタム ラベルの定義:
NSMutableArray *customArray = [[NSMutableArray alloc] initWithCapacity:[xcLabels count]];
int idx = 0;
for (NSNumber *tickLocation in xcLabels) {
CPTAxisLabel *iLabel = [[CPTAxisLabel alloc] initWithText:[xcLabels objectAtIndex:idx++] textStyle:x.labelTextStyle];
iLabel.tickLocation = CPTDecimalFromInt(idx);
iLabel.offset = x.labelOffset + x.majorTickLength;
iLabel.rotation = M_PI/2;
[customArray addObject:iLabel];
[iLabel release];
}
x.axisLabels = [NSSet setWithArray:customArray];
NSLog(@"x.axisLabels%@", x.axisLabels);
[customArray release];
majorTicklocation の定義:
NSMutableArray *ticks = [[[NSMutableArray alloc] initWithCapacity:[xcLabels count]] autorelease];
for ( NSUInteger loc = 0; loc < [xcLabels count]; ++loc ) {
[ticks addObject:[NSDecimalNumber numberWithUnsignedInteger:loc]];}
NSLog(@"tickLocations%@", ticks);
x.majorTickLocations =[NSSet setWithArray:ticks];
NSLog(@"x.majorTickLocations%@", x.majorTickLocations);
データ定義
- (void) xLabels {
xcLabels = [[NSMutableArray alloc] initWithCapacity:[self.dataGraph count]];
for (int i = 0; i < [self.dataGraph count]; ++i) {
NSNumber* nsValue = [self.dataGraph objectAtIndex:i];
CGPoint point = [nsValue CGPointValue];
NSLog(@"point.x%f", point.x);
NSDate *xFecha = [[NSDate alloc] initWithTimeIntervalSinceReferenceDate:point.x];
NSLog(@"xFecha%@", xFecha);
NSDateFormatter* df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"dd-MM"];
NSString *nstFecha = [df stringFromDate:xFecha];
[df release];
[xcLabels addObject:nstFecha];}}
x.axisLabels 出力:
x.axisLabels{(
<<CPTAxisLabel: 0x6e7c250> {<<<CPTTextLayer: 0x6e7bf60> bounds: {{0, 0}, {35, 19}}> "14-01">}>,
<<CPTAxisLabel: 0x6e7c040> {<<<CPTTextLayer: 0x6e7da30> bounds: {{0, 0}, {35, 19}}> "28-01">}>,
<<CPTAxisLabel: 0x6e7dae0> {<<<CPTTextLayer: 0x6e7db10> bounds: {{0, 0}, {35, 19}}> "14-02">}>,
<<CPTAxisLabel: 0x6e7dbc0> {<<<CPTTextLayer: 0x6e7dbf0> bounds: {{0, 0}, {35, 19}}> "25-02">}>,
<<CPTAxisLabel: 0x6e7dca0> {<<<CPTTextLayer: 0x6e7dcd0> bounds: {{0, 0}, {35, 19}}> "14-03">}>,
<<CPTAxisLabel: 0x6e7dd80> {<<<CPTTextLayer: 0x6e7ddb0> bounds: {{0, 0}, {35, 19}}> "30-03">}>,
<<CPTAxisLabel: 0x6e7de60> {<<<CPTTextLayer: 0x6e7de90> bounds: {{0, 0}, {35, 19}}> "14-04">}>,
<<CPTAxisLabel: 0x6e7df40> {<<<CPTTextLayer: 0x6e7df70> bounds: {{0, 0}, {35, 19}}> "29-04">}>,
<<CPTAxisLabel: 0x6e7e020> {<<<CPTTextLayer: 0x6e7e050> bounds: {{0, 0}, {35, 19}}> "09-05">}>,
<<CPTAxisLabel: 0x6e7e100> {<<<CPTTextLayer: 0x6e7e190> bounds: {{0, 0}, {35, 19}}> "29-08">}>,
<<CPTAxisLabel: 0x6e7e200> {<<<CPTTextLayer: 0x6e7e230> bounds: {{0, 0}, {35, 19}}> "29-09">}>,
<<CPTAxisLabel: 0x6e7e2e0> {<<<CPTTextLayer: 0x6e7e370> bounds: {{0, 0}, {35, 19}}> "27-10">}>,
<<CPTAxisLabel: 0x6e7e3e0> {<<<CPTTextLayer: 0x6e7e410> bounds: {{0, 0}, {35, 19}}> "29-11">}>,
<<CPTAxisLabel: 0x6e7e4c0> {<<<CPTTextLayer: 0x6e7e550> bounds: {{0, 0}, {35, 19}}> "28-12">}>
)}
x.majorTickLocations 出力
2012-05-29 22:21:46.960 AbcPrpk[8931:fb03] x.majorTickLocations{(
0,
13,
12,
11,
7,
6,
2,
1,
10,
9,
8,
5,
4,
3
)}