我在ios上使用coreplot并且有一个散点图。是否可以根据绘制的点改变线条样式?我只找到了如何为整个情节设置它。
答案 0 :(得分:2)
是。通过实施 - CPScatterPlotDelegate
,确保您的图表委托符合symbolForScatterPlot:recordIndex:
。这是一个工作实现,它返回与_selectedIndex
匹配的索引的不同符号:
- (CPPlotSymbol *)symbolForScatterPlot:(CPScatterPlot *)plot recordIndex:(NSUInteger)index
{
CPMutableLineStyle *symbolLineStyle = [CPMutableLineStyle lineStyle];
symbolLineStyle.lineColor = [CPColor blackColor];
CPPlotSymbol *plotSymbol = [CPPlotSymbol ellipsePlotSymbol];
plotSymbol.lineStyle = symbolLineStyle;
if (_selectedIndex != NSNotFound && index == _selectedIndex)
{
plotSymbol.symbolType = CPPlotSymbolTypeDiamond;
plotSymbol.size = CGSizeMake(12, 12);
plotSymbol.fill = [CPFill fillWithColor:[CPColor redColor]];
}
else
{
plotSymbol.symbolType = CPPlotSymbolTypeEllipse
plotSymbol.size = CGSizeMake(8, 8);
plotSymbol.fill = [CPFill fillWithColor:[CPColor greenColor]];
}
return plotSymbol;
}