Created
August 29, 2011 20:14
-
-
Save projectxcappe/1179271 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)drawRect:(CGRect)rect | |
{ | |
CGContextRef context = UIGraphicsGetCurrentContext(); | |
[self.bgColor setFill]; | |
NSUInteger count = [self.points count]; | |
CGFloat prevValX; | |
CGFloat prevValY; | |
CGFloat deltaX = LENGTH / (count - 1); | |
CGFloat deltaY = HEIGHT / (count - 1) ; | |
//allocate data points for graph | |
for(int i=1; i<count; i++){ | |
NSValue *currentPointValue = [self.points objectAtIndex:i]; | |
CGPoint currentPoint = [currentPointValue CGPointValue]; | |
CGPoint previousPoint = [[self.points objectAtIndex:i-1] CGPointValue]; | |
prevValX = previousPoint.x; | |
prevValY = previousPoint.y; | |
//Scale the graph | |
CGFloat xVal = count + (deltaX * i); | |
CGFloat yVal = currentPoint.y + (deltaY * i) ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment