Note that there are some explanatory texts on larger screens.

plurals
  1. PORibbon Graphs (charts) with Core Graphics
    text
    copied!<p>I am generating a classic line graph using core graphics, which renders and work very well. There are several lines stacking one after another using "layer.zPosition"</p> <pre><code>-(void)drawRect:(CGRect)rect { float colorChange = (0.1 * [self tag]); theFillColor = [UIColor colorWithRed:(colorChange) green:(colorChange*0.50) blue:colorChange alpha:0.75f].CGColor; CGContextRef c = UIGraphicsGetCurrentContext(); CGFloat white[4] = {1.0f, 1.0f, 1.0f, 1.0f}; CGContextSetFillColorWithColor(c, theFillColor); CGContextSetStrokeColor(c, white); CGContextSetLineWidth(c, 2.0f); CGContextBeginPath(c); // CGContextMoveToPoint(c, 0.0f, 200-[[array objectAtIndex:0] floatValue]); CGContextAddLineToPoint(c, 0.0f, 200-[[array objectAtIndex:0] floatValue]); // distancePerPoint = (rect.size.width / [array count]); float lastPointX = 750.0; for (int i = 0 ; i &lt; [array count] ; i++) { CGContextAddLineToPoint(c, (i*distancePerPoint), 200-[[array objectAtIndex:i] floatValue]); lastPointX = (i*distancePerPoint); } // CGContextAddLineToPoint(c, lastPointX, 200.0); CGContextAddLineToPoint(c, 0, 200); CGContextClosePath(c); // //CGContextFillPath(c); CGContextDrawPath(c, kCGPathFillStroke); //CGContextDrawPath(c, kCGPathStroke); } </code></pre> <p>(The above code is generating the following result): <img src="https://i.stack.imgur.com/zk9NL.jpg" alt="enter image description here"></p> <p>(I can post the code I am using for the 3d effect if needed, but the way I do it is generically by CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;)</p> <p><strong>Question:</strong> How can I transform my line graph to have depth ? I would like to have a "depth" to the line(s) graph (thus making them a ribbon) as later I would like to represent them using rotation And Perspective Transform (as stated above)</p> <p><img src="https://i.stack.imgur.com/CMmwP.jpg" alt="enter image description here"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload