0
votes

On iOS, I'm using core-plot to draw a line graph. I want the line to be bordered top and bottom with a solid color and a different color in the middle, a striping effect. This cannot be done using CPTLineStyle, so I created a custom line style that uses CGContextSetStrokePattern to draw the line.

I thought I achieve the desired effect by creating a striped image and using it as the stroke pattern. This works, but the image orientation does not follow the direction of the path. The stripes are always horizontal even if the direction of the path is 45 degrees.

How can I tell Quartz auto rotate the pattern fill such that it follows the vector direction of the graph segment? Or alternatively, how can I get core-plot to do this for me?

2

2 Answers

1
votes

We recently added the lineGradient property to CPTLineStyle that gives you a very flexible way to do this. See the "Gradient Scatter Plot" demo in the Plot Gallery example app.

Note that this change was added after the 1.3 release and is not part of a downloadable release yet. You will need to pull the latest code with Mercurial to get the change or wait for the next release.

1
votes

The best solution I've found is to use two plots. The first with the wider line style the second with the narrower one. That achieves the desired effect.