Showing
1 changed file
with
21 additions
and
19 deletions
| @@ -219,7 +219,7 @@ | @@ -219,7 +219,7 @@ | ||
| 219 | 219 | ||
| 220 | int last_x = 0; | 220 | int last_x = 0; |
| 221 | int last_y = 0; | 221 | int last_y = 0; |
| 222 | - CGFloat circle_diameter = chartData.inflexionPointWidth; | 222 | + CGFloat inflexionWidth = chartData.inflexionPointWidth; |
| 223 | 223 | ||
| 224 | for (NSUInteger i = 0; i < chartData.itemCount; i++) { | 224 | for (NSUInteger i = 0; i < chartData.itemCount; i++) { |
| 225 | 225 | ||
| @@ -233,20 +233,20 @@ | @@ -233,20 +233,20 @@ | ||
| 233 | // cycle style point | 233 | // cycle style point |
| 234 | if (chartData.inflexionPointStyle == PNLineChartPointStyleCycle) { | 234 | if (chartData.inflexionPointStyle == PNLineChartPointStyleCycle) { |
| 235 | 235 | ||
| 236 | - CGRect circleRect = CGRectMake(x-circle_diameter/2, y-circle_diameter/2, circle_diameter,circle_diameter); | 236 | + CGRect circleRect = CGRectMake(x-inflexionWidth/2, y-inflexionWidth/2, inflexionWidth,inflexionWidth); |
| 237 | CGPoint circleCenter = CGPointMake(circleRect.origin.x + (circleRect.size.width / 2), circleRect.origin.y + (circleRect.size.height / 2)); | 237 | CGPoint circleCenter = CGPointMake(circleRect.origin.x + (circleRect.size.width / 2), circleRect.origin.y + (circleRect.size.height / 2)); |
| 238 | 238 | ||
| 239 | - [pointPath moveToPoint:CGPointMake(circleCenter.x + (circle_diameter/2), circleCenter.y)]; | 239 | + [pointPath moveToPoint:CGPointMake(circleCenter.x + (inflexionWidth/2), circleCenter.y)]; |
| 240 | - [pointPath addArcWithCenter:circleCenter radius:circle_diameter/2 startAngle:0 endAngle:2*M_PI clockwise:YES]; | 240 | + [pointPath addArcWithCenter:circleCenter radius:inflexionWidth/2 startAngle:0 endAngle:2*M_PI clockwise:YES]; |
| 241 | 241 | ||
| 242 | if ( i != 0 ) { | 242 | if ( i != 0 ) { |
| 243 | 243 | ||
| 244 | // calculate the point for line | 244 | // calculate the point for line |
| 245 | float distance = sqrt( pow(x-last_x, 2) + pow(y-last_y,2) ); | 245 | float distance = sqrt( pow(x-last_x, 2) + pow(y-last_y,2) ); |
| 246 | - float last_x1 = last_x + (circle_diameter/2) / distance * (x-last_x); | 246 | + float last_x1 = last_x + (inflexionWidth/2) / distance * (x-last_x); |
| 247 | - float last_y1 = last_y + (circle_diameter/2) / distance * (y-last_y); | 247 | + float last_y1 = last_y + (inflexionWidth/2) / distance * (y-last_y); |
| 248 | - float x1 = x - (circle_diameter/2) / distance * (x-last_x); | 248 | + float x1 = x - (inflexionWidth/2) / distance * (x-last_x); |
| 249 | - float y1 = y - (circle_diameter/2) / distance * (y-last_y); | 249 | + float y1 = y - (inflexionWidth/2) / distance * (y-last_y); |
| 250 | 250 | ||
| 251 | [progressline moveToPoint:CGPointMake(last_x1, last_y1)]; | 251 | [progressline moveToPoint:CGPointMake(last_x1, last_y1)]; |
| 252 | [progressline addLineToPoint:CGPointMake(x1, y1)]; | 252 | [progressline addLineToPoint:CGPointMake(x1, y1)]; |
| @@ -258,23 +258,23 @@ | @@ -258,23 +258,23 @@ | ||
| 258 | // Square style point | 258 | // Square style point |
| 259 | else if (chartData.inflexionPointStyle == PNLineChartPointStyleSquare) { | 259 | else if (chartData.inflexionPointStyle == PNLineChartPointStyleSquare) { |
| 260 | 260 | ||
| 261 | - CGRect squareRect = CGRectMake(x-circle_diameter/2, y-circle_diameter/2, circle_diameter,circle_diameter); | 261 | + CGRect squareRect = CGRectMake(x-inflexionWidth/2, y-inflexionWidth/2, inflexionWidth,inflexionWidth); |
| 262 | CGPoint squareCenter = CGPointMake(squareRect.origin.x + (squareRect.size.width / 2), squareRect.origin.y + (squareRect.size.height / 2)); | 262 | CGPoint squareCenter = CGPointMake(squareRect.origin.x + (squareRect.size.width / 2), squareRect.origin.y + (squareRect.size.height / 2)); |
| 263 | 263 | ||
| 264 | - [pointPath moveToPoint:CGPointMake(squareCenter.x - (circle_diameter/2), squareCenter.y - (circle_diameter/2))]; | 264 | + [pointPath moveToPoint:CGPointMake(squareCenter.x - (inflexionWidth/2), squareCenter.y - (inflexionWidth/2))]; |
| 265 | - [pointPath addLineToPoint:CGPointMake(squareCenter.x + (circle_diameter/2), squareCenter.y - (circle_diameter/2))]; | 265 | + [pointPath addLineToPoint:CGPointMake(squareCenter.x + (inflexionWidth/2), squareCenter.y - (inflexionWidth/2))]; |
| 266 | - [pointPath addLineToPoint:CGPointMake(squareCenter.x + (circle_diameter/2), squareCenter.y + (circle_diameter/2))]; | 266 | + [pointPath addLineToPoint:CGPointMake(squareCenter.x + (inflexionWidth/2), squareCenter.y + (inflexionWidth/2))]; |
| 267 | - [pointPath addLineToPoint:CGPointMake(squareCenter.x - (circle_diameter/2), squareCenter.y + (circle_diameter/2))]; | 267 | + [pointPath addLineToPoint:CGPointMake(squareCenter.x - (inflexionWidth/2), squareCenter.y + (inflexionWidth/2))]; |
| 268 | [pointPath closePath]; | 268 | [pointPath closePath]; |
| 269 | 269 | ||
| 270 | if ( i != 0 ) { | 270 | if ( i != 0 ) { |
| 271 | 271 | ||
| 272 | // calculate the point for line | 272 | // calculate the point for line |
| 273 | float distance = sqrt( pow(x-last_x, 2) + pow(y-last_y,2) ); | 273 | float distance = sqrt( pow(x-last_x, 2) + pow(y-last_y,2) ); |
| 274 | - float last_x1 = last_x + (circle_diameter/2); | 274 | + float last_x1 = last_x + (inflexionWidth/2); |
| 275 | - float last_y1 = last_y + (circle_diameter/2) / distance * (y-last_y); | 275 | + float last_y1 = last_y + (inflexionWidth/2) / distance * (y-last_y); |
| 276 | - float x1 = x - (circle_diameter/2); | 276 | + float x1 = x - (inflexionWidth/2); |
| 277 | - float y1 = y - (circle_diameter/2) / distance * (y-last_y); | 277 | + float y1 = y - (inflexionWidth/2) / distance * (y-last_y); |
| 278 | 278 | ||
| 279 | [progressline moveToPoint:CGPointMake(last_x1, last_y1)]; | 279 | [progressline moveToPoint:CGPointMake(last_x1, last_y1)]; |
| 280 | [progressline addLineToPoint:CGPointMake(x1, y1)]; | 280 | [progressline addLineToPoint:CGPointMake(x1, y1)]; |
| @@ -370,8 +370,8 @@ | @@ -370,8 +370,8 @@ | ||
| 370 | for (PNLineChartData *chartData in data) { | 370 | for (PNLineChartData *chartData in data) { |
| 371 | // create as many chart line layers as there are data-lines | 371 | // create as many chart line layers as there are data-lines |
| 372 | CAShapeLayer *chartLine = [CAShapeLayer layer]; | 372 | CAShapeLayer *chartLine = [CAShapeLayer layer]; |
| 373 | - chartLine.lineCap = kCALineCapRound; | 373 | + chartLine.lineCap = kCALineCapButt; |
| 374 | - chartLine.lineJoin = kCALineJoinBevel; | 374 | + chartLine.lineJoin = kCALineJoinMiter; |
| 375 | chartLine.fillColor = [[UIColor whiteColor] CGColor]; | 375 | chartLine.fillColor = [[UIColor whiteColor] CGColor]; |
| 376 | chartLine.lineWidth = line_width; | 376 | chartLine.lineWidth = line_width; |
| 377 | chartLine.strokeEnd = 0.0; | 377 | chartLine.strokeEnd = 0.0; |
| @@ -381,6 +381,8 @@ | @@ -381,6 +381,8 @@ | ||
| 381 | // create point | 381 | // create point |
| 382 | CAShapeLayer *pointLayer = [CAShapeLayer layer]; | 382 | CAShapeLayer *pointLayer = [CAShapeLayer layer]; |
| 383 | pointLayer.strokeColor = [chartData.color CGColor]; | 383 | pointLayer.strokeColor = [chartData.color CGColor]; |
| 384 | + pointLayer.lineCap = kCALineCapRound; | ||
| 385 | + pointLayer.lineJoin = kCALineJoinBevel; | ||
| 384 | pointLayer.fillColor = nil; | 386 | pointLayer.fillColor = nil; |
| 385 | pointLayer.lineWidth = circle_stroke_width; | 387 | pointLayer.lineWidth = circle_stroke_width; |
| 386 | [self.layer addSublayer:pointLayer]; | 388 | [self.layer addSublayer:pointLayer]; |
-
Please register or login to post a comment