我正在与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;
}
最佳答案
如果要在触摸条/点时显示任何其他信息,则应实施
-(void)barPlot:(CPTBarPlot *)plot barWasSelectedAtRecordIndex:(NSUInteger)index {
}
要么
-(void)scatterPlot:(CPScatterPlot *)plot plotSymbolWasSelectedAtRecordIndex: (NSUInteger)index
{
}
委托方法(取决于图表类型)。不要忘记设置一个代表。