ios - 核心图的标注不跟随滚动

标签 ios graph core-plot callouts

我正在使用代码的修改版本 here显示图表中沿图点的标注弹出窗口。我已经让它大部分工作了,但我遇到的问题是,当我滚动或缩放图表时,标注保持在屏幕上的同一位置,而不是随着点移动而跟随。

如果您想要一些代码示例来使用,这里就是。关于如何使标注随情节点移动有什么想法吗?谢谢!

-(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];

    }
}

最佳答案

使用绘图空间委托(delegate)来监视绘图空间的更改并根据需要更新标注位置。

关于ios - 核心图的标注不跟随滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14761025/

相关文章:

ios - 在 Swift 中实现 PopOver

python - Igraph/networkx 中的 k 最短路径实现(Yen 算法)

algorithm - 通知网络所有节点的最短时间

ios - 核心图不缩放

ios - 如何使用Coreplot为绘图提供多种颜色

iOS UIScrollView 大小 subview 仅一次

iphone - 如何将文本从一个 ViewController 复制到另一个?

php - 如何使用苹果推送通知 p12 证书文件通过代码设置 ios 平台?

java - Android Graphview - 附加数据

ios - 核心图饼图上的奇怪边框