hugo-

定制饼状图

Signed-off-by: hugo- <1004581900@qq.com>
@@ -65,4 +65,7 @@ @@ -65,4 +65,7 @@
65 65
66 - (void)recompute; 66 - (void)recompute;
67 67
  68 +- (CGFloat)startPercentageForItemAtIndex:(NSUInteger)index;
  69 +- (CGFloat)endPercentageForItemAtIndex:(NSUInteger)index;
  70 +
68 @end 71 @end
@@ -26,10 +26,7 @@ @@ -26,10 +26,7 @@
26 26
27 - (UILabel *)descriptionLabelForItemAtIndex:(NSUInteger)index; 27 - (UILabel *)descriptionLabelForItemAtIndex:(NSUInteger)index;
28 - (PNPieChartDataItem *)dataItemForIndex:(NSUInteger)index; 28 - (PNPieChartDataItem *)dataItemForIndex:(NSUInteger)index;
29 -- (CGFloat)startPercentageForItemAtIndex:(NSUInteger)index;  
30 -- (CGFloat)endPercentageForItemAtIndex:(NSUInteger)index;  
31 - (CGFloat)ratioForItemAtIndex:(NSUInteger)index; 29 - (CGFloat)ratioForItemAtIndex:(NSUInteger)index;
32 -  
33 - (CAShapeLayer *)newCircleLayerWithRadius:(CGFloat)radius 30 - (CAShapeLayer *)newCircleLayerWithRadius:(CGFloat)radius
34 borderWidth:(CGFloat)borderWidth 31 borderWidth:(CGFloat)borderWidth
35 fillColor:(UIColor *)fillColor 32 fillColor:(UIColor *)fillColor
@@ -22,4 +22,13 @@ @@ -22,4 +22,13 @@
22 @property (nonatomic) UIColor *color; 22 @property (nonatomic) UIColor *color;
23 @property (nonatomic) NSString *textDescription; 23 @property (nonatomic) NSString *textDescription;
24 24
  25 +//hehejingjing
  26 +@property (nonatomic)UIColor *titlePathColor;
  27 +@property (nonatomic)CGFloat titlePathWidth;
  28 +@property (nonatomic)UIColor *titleColor;
  29 +@property (nonatomic)UIFont *titleFont;
  30 ++ (instancetype)dataItemWithValue:(CGFloat)value
  31 + color:(UIColor*)color
  32 + description:(NSString *)description titlePathColor:(UIColor *)titlePathColor titlePathLineWidth:(CGFloat)lineWidth titleColor:(UIColor *)titleColor titleFont:(UIFont *)titleFont;
  33 +
25 @end 34 @end
@@ -17,6 +17,11 @@ @@ -17,6 +17,11 @@
17 PNPieChartDataItem *item = [PNPieChartDataItem new]; 17 PNPieChartDataItem *item = [PNPieChartDataItem new];
18 item.value = value; 18 item.value = value;
19 item.color = color; 19 item.color = color;
  20 + item.textDescription = @"";
  21 + item.titlePathColor = [UIColor blackColor];
  22 + item.titlePathWidth = 0.5;
  23 + item.titleColor = [UIColor blackColor];
  24 + item.titleFont = [UIFont systemFontOfSize:12];
20 return item; 25 return item;
21 } 26 }
22 27
@@ -28,6 +33,17 @@ @@ -28,6 +33,17 @@
28 return item; 33 return item;
29 } 34 }
30 35
  36 ++ (instancetype)dataItemWithValue:(CGFloat)value
  37 + color:(UIColor*)color
  38 + description:(NSString *)description titlePathColor:(UIColor *)titlePathColor titlePathLineWidth:(CGFloat)lineWidth titleColor:(UIColor *)titleColor titleFont:(UIFont *)titleFont {
  39 + PNPieChartDataItem *item = [self dataItemWithValue:value color:color description:description];
  40 + item.titlePathColor = titlePathColor;
  41 + item.titlePathWidth = lineWidth;
  42 + item.titleColor = titleColor;
  43 + item.titleFont = titleFont;
  44 + return item;
  45 +}
  46 +
31 - (void)setValue:(CGFloat)value{ 47 - (void)setValue:(CGFloat)value{
32 NSAssert(value >= 0, @"value should >= 0"); 48 NSAssert(value >= 0, @"value should >= 0");
33 if (value != _value){ 49 if (value != _value){