0

毎月の平均記録された体重を示す散布図を取得しました。これが可能かどうかはわかりませんが、ズームインすると日ベースのチャートに変換し、ズームアウトすると月ごとに戻したいと思います。

使ってみた

-(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;
}
4

1 に答える 1

0

-scaleBy:aboutPoint:要約データから詳細データに変更するには、プロット範囲を変更するだけでなく、それ以上のことを行う必要があります。また、プロットに新しいデータ ( -reloadData) を与え、軸ラベルを更新して新しいスケールを示す必要があります。

ユーザーの操作に応じて状態を変更する必要がある場合 (たとえば、ユーザーが特定のポイントを超えてズームした場合)、デリゲートを使用してプロット スペース範囲の変更を監視し、変更のしきい値を超えたときにデータとラベルを更新します。

于 2013-11-08T13:11:57.517 に答える