我得到了一个显示每月平均记录重量的散点图。我不知道这是否可能,但我想在放大时将其转换为基于日的图表,并在缩小时转换回月度图表。
我尝试使用
-(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;
}