我正在使用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;
}
答案 0 :(得分:2)
如果您想在触摸条/点时显示任何其他信息,请执行
-(void)barPlot:(CPTBarPlot *)plot barWasSelectedAtRecordIndex:(NSUInteger)index {
}
或
-(void)scatterPlot:(CPScatterPlot *)plot plotSymbolWasSelectedAtRecordIndex: (NSUInteger)index
{
}
委托方法(取决于图表类型)。不要忘记设置一个代表。