0

グラフのプロットに沿った点から吹き出しポップアップを表示するために、ここでコードの修正版を使用しています。私はそれをほとんど機能させましたが、問題は、グラフをスクロールまたはズームすると、ポイントの移動に追従せずに、吹き出しが画面上の同じ場所にとどまることです。

試してみるコード サンプルが必要な場合は、こちらをご覧ください。吹き出しをプロット ポイントと一緒に移動させる方法についてのアイデアはありますか? ありがとう!

-(void)scatterPlot:(CPTScatterPlot *)plot plotSymbolWasSelectedAtRecordIndex:(NSUInteger)idx {
    if ([plot.identifier isEqual:_plotIdentifier]) {

        NSArray *selectedSymbolItem = [self.data.xyArrays objectAtIndex:idx];
        NSNumber *x = [selectedSymbolItem objectAtIndex:0];
        NSNumber *y = [selectedSymbolItem objectAtIndex:1];
        double doublePrecisionPlotPoint[2];
        doublePrecisionPlotPoint[0] = x.doubleValue;
        doublePrecisionPlotPoint[1] = y.doubleValue;
        CGPoint pointTouched = [plot.graph.defaultPlotSpace plotAreaViewPointForDoublePrecisionPlotPoint:doublePrecisionPlotPoint];

        CGPoint convertedPoint = [plot.graph convertPoint:pointTouched toLayer:self.view.layer];

        _popupView = [[SMCalloutView alloc] init];
        _popupView.title = [NSString stringWithFormat:@"Thing %i", idx];
        [_popupView presentCalloutFromRect:CGRectMake(convertedPoint.x, convertedPoint.y, 10, 10) inLayer:self.view.layer constrainedToLayer:self.hostView.layer permittedArrowDirections:SMCalloutArrowDirectionDown animated:YES];

    }
}
4

1 に答える 1

1

プロット スペース デリゲートを使用して、プロット スペースの変更を監視し、必要に応じて吹き出しの位置を更新します。

于 2013-02-08T01:59:05.063 に答える