毎月の平均記録された体重を示す散布図を取得しました。これが可能かどうかはわかりませんが、ズームインすると日ベースのチャートに変換し、ズームアウトすると月ごとに戻したいと思います。
使ってみた
-(void)scaleBy: (CGFloat)interactionScale aboutPoint: (CGPoint)interactionPoint
しかし、使用してズームインまたはズームアウトしたかどうかはわかりませんinteractionScale
必要に応じて、データソース コードを次に示します。
- (NSNumber *)numberForPlot: (CPTPlot *)plot field: (NSUInteger)fieldEnum recordIndex: (NSUInteger)index {
switch (fieldEnum) {
case CPTScatterPlotFieldX:
if (index < 13) {
if (index == 0)
return nil;
//NSLog(@"x coordinate: %i",index);
return [NSNumber numberWithUnsignedInteger: index];
}
break;
case CPTScatterPlotFieldY:
if (index == 0)
return nil;
//NSLog(@"y coordinate: %i", [[weights objectAtIndex: index]integerValue]);
if ([[weights objectAtIndex: index]integerValue] <= 0)
return nil;
else return [NSNumber numberWithUnsignedInteger: [[weights objectAtIndex: index]integerValue]];
break;
}
return [NSDecimalNumber zero];
}
- (CPTLayer *)dataLabelForPlot: (CPTPlot *)plot recordIndex: (NSUInteger)idx {
CPTMutableTextStyle *axisTitleTextStyle = [CPTMutableTextStyle textStyle];
axisTitleTextStyle.fontSize = 10.0;
axisTitleTextStyle.fontName = @"Helvetica-Bold";
axisTitleTextStyle.color = [CPTColor whiteColor];
CPTTextLayer *label = [[CPTTextLayer alloc] init];
label.textStyle = axisTitleTextStyle;
label.text = [NSString stringWithFormat: @"%.2f", [[weights objectAtIndex: idx] floatValue]];
return label;
}