Toggle navigation
Toggle navigation
This project
Loading...
Sign in
iOS
/
PNChart
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Leii
2015-07-23 10:00:33 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6d474c4f17b463e4d78e7741a981aabb692d0f64
6d474c4f
1 parent
8d9425ea
Make the syntax more standardized.
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
29 deletions
PNChart/PNRadarChart.h
PNChart/PNRadarChart.m
PNChart/PNRadarChartDataItem.m
PNChart/PNRadarChart.h
View file @
6d474c4
...
...
@@ -27,26 +27,26 @@ typedef NS_ENUM(NSUInteger, PNRadarChartLabelStyle) {
-
(
void
)
strokeChart
;
/** Array of `RadarChartDataItem` objects, one for each corner. */
@property
(
nonatomic
)
NSArray
*
chartData
;
@property
(
nonatomic
)
NSArray
*
chartData
;
/** The unit of this chart ,default is 1 */
@property
(
nonatomic
)
CGFloat
valueDivider
;
@property
(
nonatomic
)
CGFloat
valueDivider
;
/** The maximum for the range of values to display on the chart */
@property
(
nonatomic
)
CGFloat
maxValue
;
@property
(
nonatomic
)
CGFloat
maxValue
;
/** Default is gray. */
@property
(
nonatomic
)
UIColor
*
webColor
;
@property
(
nonatomic
)
UIColor
*
webColor
;
/** Default is green , with an alpha of 0.7 */
@property
(
nonatomic
)
UIColor
*
plotColor
;
@property
(
nonatomic
)
UIColor
*
plotColor
;
/** Default is black */
@property
(
nonatomic
)
UIColor
*
fontColor
;
@property
(
nonatomic
)
UIColor
*
fontColor
;
/** Default is orange */
@property
(
nonatomic
)
UIColor
*
graduationColor
;
@property
(
nonatomic
)
UIColor
*
graduationColor
;
/** Default is 15 */
@property
(
nonatomic
)
CGFloat
fontSize
;
@property
(
nonatomic
)
CGFloat
fontSize
;
/** Controls the labels display style that around chart */
@property
(
nonatomic
,
assign
)
PNRadarChartLabelStyle
labelStyle
;
@property
(
nonatomic
,
assign
)
PNRadarChartLabelStyle
labelStyle
;
/** Tap the label will display detail value ,default is YES. */
@property
(
nonatomic
,
assign
)
BOOL
isLabelTouchable
;
@property
(
nonatomic
,
assign
)
BOOL
isLabelTouchable
;
/** is show graduation on the chart ,default is NO. */
@property
(
nonatomic
,
assign
)
BOOL
isShowGraduation
;
@property
(
nonatomic
,
assign
)
BOOL
isShowGraduation
;
@end
...
...
PNChart/PNRadarChart.m
View file @
6d474c4
...
...
@@ -10,19 +10,20 @@
@interface
PNRadarChart
()
@property
(
nonatomic
)
CGFloat
centerX
;
@property
(
nonatomic
)
CGFloat
centerY
;
@property
(
nonatomic
)
NSMutableArray
*
pointsToWebArrayArray
;
@property
(
nonatomic
)
NSMutableArray
*
pointsToPlotArray
;
@property
(
nonatomic
)
UILabel
*
detailLabel
;
@property
(
nonatomic
)
CGFloat
lengthUnit
;
@property
(
nonatomic
)
CAShapeLayer
*
chartPlot
;
@property
(
nonatomic
)
CGFloat
centerX
;
@property
(
nonatomic
)
CGFloat
centerY
;
@property
(
nonatomic
)
NSMutableArray
*
pointsToWebArrayArray
;
@property
(
nonatomic
)
NSMutableArray
*
pointsToPlotArray
;
@property
(
nonatomic
)
UILabel
*
detailLabel
;
@property
(
nonatomic
)
CGFloat
lengthUnit
;
@property
(
nonatomic
)
CAShapeLayer
*
chartPlot
;
@end
@implementation
PNRadarChart
-
(
id
)
initWithFrame
:(
CGRect
)
frame
items
:(
NSArray
*
)
items
valueDivider
:(
CGFloat
)
unitValue
{
-
(
id
)
initWithFrame
:(
CGRect
)
frame
items
:(
NSArray
*
)
items
valueDivider
:(
CGFloat
)
unitValue
{
self
=
[
super
initWithFrame
:
frame
];
if
(
self
)
{
self
.
backgroundColor
=
[
UIColor
clearColor
];
...
...
@@ -80,7 +81,7 @@
}
#pragma mark - main
-
(
void
)
calculateChartPoints
{
-
(
void
)
calculateChartPoints
{
[
_pointsToPlotArray
removeAllObjects
];
[
_pointsToWebArrayArray
removeAllObjects
];
...
...
@@ -181,7 +182,7 @@
}
-
(
void
)
strokeChart
{
-
(
void
)
strokeChart
{
[
self
calculateChartPoints
];
[
self
setNeedsDisplay
];
...
...
@@ -226,7 +227,7 @@
#pragma mark - Helper
-
(
void
)
drawLabelWithMaxLength
:
(
CGFloat
)
maxLength
labelArray
:
(
NSArray
*
)
labelArray
angleArray
:
(
NSArray
*
)
angleArray
{
-
(
void
)
drawLabelWithMaxLength
:
(
CGFloat
)
maxLength
labelArray
:
(
NSArray
*
)
labelArray
angleArray
:
(
NSArray
*
)
angleArray
{
//set labels
int
labelTag
=
121
;
while
(
true
)
{
...
...
@@ -283,7 +284,7 @@
}
-
(
void
)
tapLabel
:
(
UITapGestureRecognizer
*
)
recognizer
{
-
(
void
)
tapLabel
:
(
UITapGestureRecognizer
*
)
recognizer
{
UILabel
*
label
=
(
UILabel
*
)
recognizer
.
view
;
_detailLabel
.
frame
=
CGRectMake
(
label
.
frame
.
origin
.
x
,
label
.
frame
.
origin
.
y
-
30
,
50
,
25
);
for
(
PNRadarChartDataItem
*
item
in
_chartData
)
{
...
...
@@ -296,7 +297,7 @@
}
-
(
void
)
showGraduation
{
-
(
void
)
showGraduation
{
int
labelTag
=
112
;
while
(
true
)
{
UIView
*
label
=
[
self
viewWithTag
:
labelTag
];
...
...
@@ -322,7 +323,7 @@
}
-
(
NSArray
*
)
getWebPointWithLength
:
(
CGFloat
)
length
angleArray
:
(
NSArray
*
)
angleArray
{
-
(
NSArray
*
)
getWebPointWithLength
:
(
CGFloat
)
length
angleArray
:
(
NSArray
*
)
angleArray
{
NSMutableArray
*
pointArray
=
[
NSMutableArray
array
];
for
(
NSNumber
*
angleNumber
in
angleArray
)
{
CGFloat
angle
=
[
angleNumber
floatValue
];
...
...
@@ -334,7 +335,7 @@
}
-
(
NSArray
*
)
getLengthArrayWithCircleNum
:
(
int
)
plotCircles
{
-
(
NSArray
*
)
getLengthArrayWithCircleNum
:
(
int
)
plotCircles
{
NSMutableArray
*
lengthArray
=
[
NSMutableArray
array
];
CGFloat
length
=
0
;
for
(
int
i
=
0
;
i
<
plotCircles
;
i
++
)
{
...
...
@@ -344,7 +345,7 @@
return
lengthArray
;
}
-
(
CGFloat
)
getMaxWidthLabelFromArray
:
(
NSArray
*
)
keyArray
withFontSize
:
(
CGFloat
)
size
{
-
(
CGFloat
)
getMaxWidthLabelFromArray
:
(
NSArray
*
)
keyArray
withFontSize
:
(
CGFloat
)
size
{
CGFloat
maxWidth
=
0
;
for
(
NSString
*
str
in
keyArray
)
{
CGSize
detailSize
=
[
str
sizeWithAttributes
:@{
NSFontAttributeName
:
[
UIFont
systemFontOfSize
:
_fontSize
]}];
...
...
@@ -353,7 +354,7 @@
return
maxWidth
;
}
-
(
CGFloat
)
getMaxValueFromArray
:
(
NSArray
*
)
valueArray
{
-
(
CGFloat
)
getMaxValueFromArray
:
(
NSArray
*
)
valueArray
{
CGFloat
max
=
_maxValue
;
for
(
NSNumber
*
valueNum
in
valueArray
)
{
CGFloat
valueFloat
=
[
valueNum
floatValue
];
...
...
PNChart/PNRadarChartDataItem.m
View file @
6d474c4
...
...
@@ -18,7 +18,7 @@
return
item
;
}
-
(
void
)
setValue
:(
CGFloat
)
value
{
-
(
void
)
setValue
:(
CGFloat
)
value
{
if
(
value
<
0
)
{
_value
=
0
;
NSLog
(
@"Value value can not be negative"
);
...
...
Please
register
or
login
to post a comment