在悬停它时在CPTPlotSymbol上显示工具提示

时间:2013-11-25 10:04:33

标签: ios iphone objective-c cocoa-touch core-plot

我正在使用Core Plot绘制散点图。它工作正常。但是我希望在悬停CPTPlotSymbol时显示当前值。请看下面的图片: enter image description here

以下是示例代码:

- (void)configurePlots
{
[...]
    CPTMutableLineStyle *lineStyle = [myPlot.dataLineStyle mutableCopy];
    lineStyle.lineWidth = 2.5;
    lineStyle.lineColor = [CPTColor greenColor];
    myPlot.dataLineStyle = lineStyle;
    CPTMutableLineStyle *symbolLineStyle = [CPTMutableLineStyle lineStyle];
    symbolLineStyle.lineColor = [CPTColor greenColor];
    CPTPlotSymbol *symbol = [CPTPlotSymbol ellipsePlotSymbol];
    symbol.fill = [CPTFill fillWithColor:[CPTColor greenColor]];
    symbol.lineStyle = symbolLineStyle;
    symbol.size = CGSizeMake(6.0f, 6.0f);
    myPlot.plotSymbol = symbol;
}

1 个答案:

答案 0 :(得分:2)

如果您想在触摸条/点时显示任何其他信息,请执行

    -(void)barPlot:(CPTBarPlot *)plot barWasSelectedAtRecordIndex:(NSUInteger)index {
}

-(void)scatterPlot:(CPScatterPlot *)plot plotSymbolWasSelectedAtRecordIndex:    (NSUInteger)index
{
}

委托方法(取决于图表类型)。不要忘记设置一个代表。