Kevin

Merge pull request #119 from MrWooJ/fixing-Issue#70

Fixing issue#70
@@ -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 ) {
@@ -8,7 +8,8 @@ @@ -8,7 +8,8 @@
8 typedef NS_ENUM(NSUInteger, PNLineChartPointStyle) { 8 typedef NS_ENUM(NSUInteger, PNLineChartPointStyle) {
9 PNLineChartPointStyleNone = 0, 9 PNLineChartPointStyleNone = 0,
10 PNLineChartPointStyleCircle = 1, 10 PNLineChartPointStyleCircle = 1,
11 - PNLineChartPointStyleSquare = 3 11 + PNLineChartPointStyleSquare = 3,
  12 + PNLineChartPointStyleTriangle = 4
12 }; 13 };
13 14
14 @class PNLineChartDataItem; 15 @class PNLineChartDataItem;
@@ -38,7 +38,7 @@ @@ -38,7 +38,7 @@
38 PNLineChartData *data01 = [PNLineChartData new]; 38 PNLineChartData *data01 = [PNLineChartData new];
39 data01.color = PNFreshGreen; 39 data01.color = PNFreshGreen;
40 data01.itemCount = lineChart.xLabels.count; 40 data01.itemCount = lineChart.xLabels.count;
41 - data01.inflexionPointStyle = PNLineChartPointStyleCircle; 41 + data01.inflexionPointStyle = PNLineChartPointStyleTriangle;
42 data01.getData = ^(NSUInteger index) { 42 data01.getData = ^(NSUInteger index) {
43 CGFloat yValue = [data01Array[index] floatValue]; 43 CGFloat yValue = [data01Array[index] floatValue];
44 return [PNLineChartDataItem dataItemWithY:yValue]; 44 return [PNLineChartDataItem dataItemWithY:yValue];