adding code for triangle point
triangle point in linebar chart
Showing
1 changed file
with
30 additions
and
0 deletions
| @@ -331,6 +331,36 @@ | @@ -331,6 +331,36 @@ | ||
| 331 | 331 | ||
| 332 | last_x = x; | 332 | last_x = x; |
| 333 | last_y = y; | 333 | last_y = y; |
| 334 | + } | ||
| 335 | + // Triangle point | ||
| 336 | + else if (chartData.inflexionPointStyle == PNLineChartPointStyleTriangle) { | ||
| 337 | + | ||
| 338 | + CGRect squareRect = CGRectMake(x - inflexionWidth / 2, y - inflexionWidth / 2, inflexionWidth, inflexionWidth); | ||
| 339 | + | ||
| 340 | + CGPoint startPoint = CGPointMake(squareRect.origin.x,squareRect.origin.y + squareRect.size.height); | ||
| 341 | + CGPoint endPoint = CGPointMake(squareRect.origin.x + (squareRect.size.width / 2) , squareRect.origin.y); | ||
| 342 | + CGPoint middlePoint = CGPointMake(squareRect.origin.x + (squareRect.size.width) , squareRect.origin.y + squareRect.size.height); | ||
| 343 | + | ||
| 344 | + [pointPath moveToPoint:startPoint]; | ||
| 345 | + [pointPath addLineToPoint:middlePoint]; | ||
| 346 | + [pointPath addLineToPoint:endPoint]; | ||
| 347 | + [pointPath closePath]; | ||
| 348 | + | ||
| 349 | + if ( i != 0 ) { | ||
| 350 | + // calculate the point for triangle | ||
| 351 | + float distance = sqrt(pow(x - last_x, 2) + pow(y - last_y, 2) ) * 1.4 ; | ||
| 352 | + float last_x1 = last_x + (inflexionWidth / 2) / distance * (x - last_x); | ||
| 353 | + float last_y1 = last_y + (inflexionWidth / 2) / distance * (y - last_y); | ||
| 354 | + float x1 = x - (inflexionWidth / 2) / distance * (x - last_x); | ||
| 355 | + float y1 = y - (inflexionWidth / 2) / distance * (y - last_y); | ||
| 356 | + | ||
| 357 | + [progressline moveToPoint:CGPointMake(last_x1, last_y1)]; | ||
| 358 | + [progressline addLineToPoint:CGPointMake(x1, y1)]; | ||
| 359 | + } | ||
| 360 | + | ||
| 361 | + last_x = x; | ||
| 362 | + last_y = y; | ||
| 363 | + | ||
| 334 | } else { | 364 | } else { |
| 335 | 365 | ||
| 336 | if ( i != 0 ) { | 366 | if ( i != 0 ) { |
-
Please register or login to post a comment