sri
sri

Reputation: 3389

How do you draw vertical line using coreplot CPPlotSymbol?

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

Sri

Upvotes: 0

Views: 1838

Answers (1)

Eric Skroch
Eric Skroch

Reputation: 27381

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.

Upvotes: 2

Related Questions