【问题标题】:Display a tooltip on CPTPlotSymbol when hover it悬停时在 CPTPlotSymbol 上显示工具提示
【发布时间】:2013-11-25 10:04:33
【问题描述】:

我正在使用 Core Plot 绘制散点图。它工作正常。但我想在悬停 CPTPlotSymbol 时显示当前值。请看下图:

这是一个示例代码:

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

【问题讨论】:

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


    【解决方案1】:

    如果您想在触摸条/点时显示任何附加信息,您应该实现

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-06-18
      • 1970-01-01
      • 1970-01-01
      • 2014-03-29
      • 2022-08-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多