How do you draw vertical line using coreplot CPPlotSymbol?

那年仲夏 提交于 2019-12-08 12:22:32

问题


How do I draw a vertical line on plotSymbol using Custom PlotSymbol? If it would be grateful, give any samples regarding that.

Sri


回答1:


You simply create a CGPath that describes the outline of your custom symbol. Here's a sample from CPTestApp (in the CorePlot/examples folder):

CPPlotSymbol *symbol = [[[CPPlotSymbol alloc] init] autorelease];
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, NULL, 0., 0.);

CGPathAddEllipseInRect(path, NULL, CGRectMake(0., 0., 10., 10.));
CGPathAddEllipseInRect(path, NULL, CGRectMake(1.5, 4., 3., 3.));
CGPathAddEllipseInRect(path, NULL, CGRectMake(5.5, 4., 3., 3.));
CGPathMoveToPoint(path, NULL, 5., 2.);
CGPathAddArc(path, NULL, 5., 3.3, 2.8, 0., pi, TRUE);
CGPathCloseSubpath(path);

symbol.customSymbolPath = path;
symbol.usesEvenOddClipRule = YES;
CGPathRelease(path);

You can set the plotSymbol property on the scatter plot to apply your symbol to every point or use the -symbolForScatterPlot:recordIndex: or -symbolsForScatterPlot:recordIndexRange: datasource method to apply it to some of the points.



来源:https://stackoverflow.com/questions/3226423/how-do-you-draw-vertical-line-using-coreplot-cpplotsymbol

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!