单军华
2017-03-03 764722d0366346dc435aa906abdd25655e3b0769
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//
//  PNBarChart.h
//  PNChartDemo
//
//  Created by kevin on 11/7/13.
//  Copyright (c) 2013年 kevinzhow. All rights reserved.
//
 
#import <UIKit/UIKit.h>
#import "PNGenericChart.h"
#import "PNChartDelegate.h"
#import "PNBar.h"
 
#define kXLabelMargin 15
#define kYLabelMargin 15
#define kYLabelHeight 11
#define kXLabelHeight 20
 
typedef NSString *(^PNYLabelFormatter)(CGFloat yLabelValue);
 
@interface PNBarChart : PNGenericChart
 
/**
 * Draws the chart in an animated fashion.
 */
- (void)strokeChart;
 
@property (nonatomic) NSArray *xLabels;
@property (nonatomic) NSArray *yLabels;
@property (nonatomic) NSArray *yValues;
 
@property (nonatomic) NSMutableArray * bars;
 
@property (nonatomic) CGFloat xLabelWidth;
@property (nonatomic) float yValueMax;
@property (nonatomic) UIColor *strokeColor;
@property (nonatomic) NSArray *strokeColors;
 
 
/** Update Values. */
- (void)updateChartData:(NSArray *)data;
 
/** Changes chart margin. */
@property (nonatomic) CGFloat yChartLabelWidth;
 
/** Formats the ylabel text. */
@property (copy) PNYLabelFormatter yLabelFormatter;
 
/** Prefix to y label values, none if unset. */
@property (nonatomic) NSString *yLabelPrefix;
 
/** Suffix to y label values, none if unset. */
@property (nonatomic) NSString *yLabelSuffix;
 
@property (nonatomic) CGFloat chartMarginLeft;
@property (nonatomic) CGFloat chartMarginRight;
@property (nonatomic) CGFloat chartMarginTop;
@property (nonatomic) CGFloat chartMarginBottom;
 
/** Controls whether labels should be displayed. */
@property (nonatomic) BOOL showLabel;
 
/** Controls whether the chart border line should be displayed. */
@property (nonatomic) BOOL showChartBorder;
 
@property (nonatomic) UIColor *chartBorderColor;
 
/** Controls whether the chart Horizontal separator should be displayed. */
@property (nonatomic, assign) BOOL showLevelLine;
 
/** Chart bottom border, co-linear with the x-axis. */
@property (nonatomic) CAShapeLayer * chartBottomLine;
 
/** Chart bottom border, level separator-linear with the x-axis. */
@property (nonatomic) CAShapeLayer * chartLevelLine;
 
/** Chart left border, co-linear with the y-axis. */
@property (nonatomic) CAShapeLayer * chartLeftLine;
 
/** Corner radius for all bars in the chart. */
@property (nonatomic) CGFloat barRadius;
 
/** Width of all bars in the chart. */
@property (nonatomic) CGFloat barWidth;
 
@property (nonatomic) CGFloat labelMarginTop;
 
/** Background color of all bars in the chart. */
@property (nonatomic) UIColor * barBackgroundColor;
 
/** Text color for all bars in the chart. */
@property (nonatomic) UIColor * labelTextColor;
 
/** Font for all bars in the chart. */
@property (nonatomic) UIFont * labelFont;
 
/** How many labels on the x-axis to skip in between displaying labels. */
@property (nonatomic) NSInteger xLabelSkip;
 
/** How many labels on the y-axis to skip in between displaying labels. */
@property (nonatomic) NSInteger yLabelSum;
 
/** The maximum for the range of values to display on the y-axis. */
@property (nonatomic) CGFloat yMaxValue;
 
/** The minimum for the range of values to display on the y-axis. */
@property (nonatomic) CGFloat yMinValue;
 
/** Controls whether each bar should have a gradient fill. */
@property (nonatomic) UIColor *barColorGradientStart;
 
/** Controls whether text for x-axis be straight or rotate 45 degree. */
@property (nonatomic) BOOL rotateForXAxisText;
 
@property (nonatomic, weak) id<PNChartDelegate> delegate;
 
/**whether show gradient bar*/
@property (nonatomic, assign) BOOL isGradientShow;
 
/** whether show numbers*/
@property (nonatomic, assign) BOOL isShowNumbers;
 
@end