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
kevinzhow
2013-12-12 09:17:03 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a7b298ff638b21e69f9ebcdf97bfd7f5380ab73c
a7b298ff
1 parent
1048a720
Remove PNChart proxy which is not cool
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
10 additions
and
204 deletions
PNChartDemo.xcodeproj/project.pbxproj
PNChartDemo/PCChartsTableViewController.m
PNChartDemo/PNChart/PNChart.h
PNChartDemo/PNChart/PNChart.m
PNChartDemo/PNChart/PNCircleChart.m
PNChartDemo/PNChart/PNLineChart.m
PNChartDemo.xcodeproj/project.pbxproj
View file @
a7b298f
...
...
@@ -21,7 +21,6 @@
0AF7A889182AA9F6003645C4 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0AF7A86B182AA9F6003645C4 /* UIKit.framework */; };
0AF7A891182AA9F6003645C4 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0AF7A88F182AA9F6003645C4 /* InfoPlist.strings */; };
0AF7A893182AA9F6003645C4 /* PNChartDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AF7A892182AA9F6003645C4 /* PNChartDemoTests.m */; };
0AF7A8A1182AAAAA003645C4 /* PNChart.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AF7A8A0182AAAAA003645C4 /* PNChart.m */; };
0AF7A8AF182AAEEF003645C4 /* PCChartViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AF7A8AE182AAEEF003645C4 /* PCChartViewController.m */; };
0AF7A8B3182AC604003645C4 /* PNLineChart.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AF7A8B2182AC604003645C4 /* PNLineChart.m */; };
0AF7A8B6182ADDEB003645C4 /* PNBarChart.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AF7A8B5182ADDEB003645C4 /* PNBarChart.m */; };
...
...
@@ -63,7 +62,6 @@
0AF7A890182AA9F6003645C4 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
0AF7A892182AA9F6003645C4 /* PNChartDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PNChartDemoTests.m; sourceTree = "<group>"; };
0AF7A89F182AAAAA003645C4 /* PNChart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PNChart.h; path = PNChart/PNChart.h; sourceTree = "<group>"; };
0AF7A8A0182AAAAA003645C4 /* PNChart.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PNChart.m; path = PNChart/PNChart.m; sourceTree = "<group>"; };
0AF7A8AD182AAEEF003645C4 /* PCChartViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PCChartViewController.h; sourceTree = "<group>"; };
0AF7A8AE182AAEEF003645C4 /* PCChartViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PCChartViewController.m; sourceTree = "<group>"; };
0AF7A8B1182AC604003645C4 /* PNLineChart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PNLineChart.h; path = PNChart/PNLineChart.h; sourceTree = "<group>"; };
...
...
@@ -190,7 +188,6 @@
9F656B49184A4B90002E5675 /* PNLineChart */,
9F656B4A184A4BAC002E5675 /* PNChartUI */,
0AF7A89F182AAAAA003645C4 /* PNChart.h */,
0AF7A8A0182AAAAA003645C4 /* PNChart.m */,
9F656B48184A4B83002E5675 /* PNBarChart */,
9F656B4B184A4BC9002E5675 /* PNCircleChart */,
9FE9CFB818581102005B8223 /* PNChartDelegate.h */,
...
...
@@ -355,7 +352,6 @@
9FA23B10184A5944002DBBA4 /* PCChartsTableViewController.m in Sources */,
0AF7A8BE182AEB99003645C4 /* PNChartLabel.m in Sources */,
0AF7A8B9182AEB80003645C4 /* PNBar.m in Sources */,
0AF7A8A1182AAAAA003645C4 /* PNChart.m in Sources */,
0AF7A8B6182ADDEB003645C4 /* PNBarChart.m in Sources */,
0AF7A874182AA9F6003645C4 /* main.m in Sources */,
0AF7A8B3182AC604003645C4 /* PNLineChart.m in Sources */,
...
...
PNChartDemo/PCChartsTableViewController.m
View file @
a7b298f
...
...
@@ -58,11 +58,12 @@
lineChartLabel
.
font
=
[
UIFont
fontWithName
:
@"Avenir-Medium"
size
:
23
.
0
];
lineChartLabel
.
textAlignment
=
NSTextAlignmentCenter
;
PN
Chart
*
lineChart
=
[[
PN
Chart
alloc
]
initWithFrame
:
CGRectMake
(
0
,
135
.
0
,
SCREEN_WIDTH
,
200
.
0
)];
PN
LineChart
*
lineChart
=
[[
PNLine
Chart
alloc
]
initWithFrame
:
CGRectMake
(
0
,
135
.
0
,
SCREEN_WIDTH
,
200
.
0
)];
lineChart
.
backgroundColor
=
[
UIColor
clearColor
];
[
lineChart
setXLabels
:@[
@"SEP 1"
,
@"SEP 2"
,
@"SEP 3"
,
@"SEP 4"
,
@"SEP 5"
,
@"SEP 6"
,
@"SEP 7"
]];
[
lineChart
setYValues
:@[
@1
,
@24
,
@12
,
@18
,
@30
,
@10
,
@21
]];
[
lineChart
strokeChart
];
lineChart
.
delegate
=
self
;
[
viewController
.
view
addSubview
:
lineChartLabel
];
...
...
@@ -80,9 +81,8 @@
barChartLabel
.
font
=
[
UIFont
fontWithName
:
@"Avenir-Medium"
size
:
23
.
0
];
barChartLabel
.
textAlignment
=
NSTextAlignmentCenter
;
PN
Chart
*
barChart
=
[[
PN
Chart
alloc
]
initWithFrame
:
CGRectMake
(
0
,
135
.
0
,
SCREEN_WIDTH
,
200
.
0
)];
PN
BarChart
*
barChart
=
[[
PNBar
Chart
alloc
]
initWithFrame
:
CGRectMake
(
0
,
135
.
0
,
SCREEN_WIDTH
,
200
.
0
)];
barChart
.
backgroundColor
=
[
UIColor
clearColor
];
barChart
.
type
=
PNBarType
;
[
barChart
setXLabels
:@[
@"SEP 1"
,
@"SEP 2"
,
@"SEP 3"
,
@"SEP 4"
,
@"SEP 5"
,
@"SEP 6"
,
@"SEP 7"
]];
[
barChart
setYValues
:@[
@1
,
@24
,
@12
,
@18
,
@30
,
@10
,
@21
]];
[
barChart
strokeChart
];
...
...
@@ -103,17 +103,15 @@
circleChartLabel
.
font
=
[
UIFont
fontWithName
:
@"Avenir-Medium"
size
:
23
.
0
];
circleChartLabel
.
textAlignment
=
NSTextAlignmentCenter
;
PNC
hart
*
circleChart
=
[[
PNChart
alloc
]
initWithFrame
:
CGRectMake
(
0
,
135
.
0
,
SCREEN_WIDTH
,
100
.
0
)
];
PNC
ircleChart
*
circleChart
=
[[
PNCircleChart
alloc
]
initWithFrame
:
CGRectMake
(
0
,
80
.
0
,
SCREEN_WIDTH
,
100
.
0
)
andTotal
:[
NSNumber
numberWithInt
:
100
]
andCurrent
:
[
NSNumber
numberWithInt
:
60
]
];
circleChart
.
backgroundColor
=
[
UIColor
clearColor
];
circleChart
.
type
=
PNCircleType
;
circleChart
.
total
=
[
NSNumber
numberWithInt
:
100
];
circleChart
.
current
=
[
NSNumber
numberWithInt
:
60
];
[
circleChart
setStrokeColor
:
PNGreen
];
[
circleChart
strokeChart
];
[
viewController
.
view
addSubview
:
circleChartLabel
];
[
viewController
.
view
addSubview
:
circleChart
];
viewController
.
title
=
@"Circle Chart"
;
}
}
...
...
PNChartDemo/PNChart/PNChart.h
View file @
a7b298f
...
...
@@ -14,94 +14,3 @@
#import "PNBarChart.h"
#import "PNCircleChart.h"
#import "PNChartDelegate.h"
typedef
enum
{
/** Solid line chart style */
PNLineType
,
/** Bar chart style with bar background color */
PNBarType
,
/** Circle chart */
PNCircleType
}
PNChartType
;
@interface
PNChart
:
UIView
<
PNChartDelegate
>
/**
* PNChart delegate.
*/
@property
(
nonatomic
,
retain
)
id
<
PNChartDelegate
>
delegate
;
/**
* This method will call and troke the line in animation.
*/
-
(
void
)
strokeChart
;
/**
* X Labels will show on chart.
*
*/
@property
(
strong
,
nonatomic
)
NSArray
*
xLabels
;
/**
* Y value for X label, Chart will generate the Y label by it self.
*
*/
@property
(
strong
,
nonatomic
)
NSArray
*
yValues
;
@property
(
strong
,
nonatomic
)
PNLineChart
*
lineChart
;
@property
(
strong
,
nonatomic
)
PNBarChart
*
barChart
;
@property
(
strong
,
nonatomic
)
PNCircleChart
*
circleChart
;
/**
* PNChart chart type. The default is PNLineChart.
*
* @see PNChartType
*/
@property
(
assign
)
PNChartType
type
;
/**
* PNChart chart stroke color. The default is PNGreen.
*
*/
@property
(
nonatomic
,
strong
)
UIColor
*
strokeColor
;
/**
* PNChart bar chart background color. The default is PNLightGrey.
*
*/
@property
(
nonatomic
,
strong
)
UIColor
*
barBackgroundColor
;
/**
* PNChart circle chart total number.
*
*/
@property
(
nonatomic
,
strong
)
NSNumber
*
total
;
/**
* PNChart circle chart current number.
*
*/
@property
(
nonatomic
,
strong
)
NSNumber
*
current
;
/**
* PNChart if chart show labels.
*
*/
@property
(
nonatomic
)
BOOL
showLabel
;
@end
...
...
PNChartDemo/PNChart/PNChart.m
deleted
100644 → 0
View file @
1048a72
//
// PNChart.m
// PNChart
//
// Created by kevin on 10/3/13.
// Copyright (c) 2013年 kevinzhow. All rights reserved.
//
#import "PNChart.h"
@implementation
PNChart
-
(
id
)
initWithFrame
:(
CGRect
)
frame
{
self
=
[
super
initWithFrame
:
frame
];
if
(
self
)
{
// Initialization code
self
.
backgroundColor
=
[
UIColor
whiteColor
];
self
.
clipsToBounds
=
NO
;
self
.
type
=
PNLineType
;
_showLabel
=
YES
;
self
.
strokeColor
=
PNFreshGreen
;
}
return
self
;
}
-
(
void
)
setUpChart
{
if
(
self
.
type
==
PNLineType
)
{
_lineChart
=
[[
PNLineChart
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
self
.
frame
.
size
.
width
,
self
.
frame
.
size
.
height
)];
_lineChart
.
backgroundColor
=
[
UIColor
clearColor
];
_lineChart
.
showLabel
=
_showLabel
;
[
self
addSubview
:
_lineChart
];
[
_lineChart
setYValues
:
_yValues
];
[
_lineChart
setXLabels
:
_xLabels
];
[
_lineChart
setStrokeColor
:
_strokeColor
];
[
_lineChart
strokeChart
];
_lineChart
.
delegate
=
self
;
}
else
if
(
self
.
type
==
PNBarType
)
{
_barChart
=
[[
PNBarChart
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
self
.
frame
.
size
.
width
,
self
.
frame
.
size
.
height
)];
_barChart
.
backgroundColor
=
[
UIColor
clearColor
];
if
(
_barBackgroundColor
)
{
_barChart
.
barBackgroundColor
=
_barBackgroundColor
;
}
_barChart
.
showLabel
=
_showLabel
;
[
self
addSubview
:
_barChart
];
[
_barChart
setYValues
:
_yValues
];
[
_barChart
setXLabels
:
_xLabels
];
[
_barChart
setStrokeColor
:
_strokeColor
];
[
_barChart
strokeChart
];
}
else
if
(
self
.
type
==
PNCircleType
)
{
_circleChart
=
[[
PNCircleChart
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
self
.
frame
.
size
.
width
,
self
.
frame
.
size
.
height
)
andTotal
:
self
.
total
andCurrent
:
self
.
current
];
_circleChart
.
backgroundColor
=
[
UIColor
clearColor
];
_circleChart
.
lineWidth
=
[
NSNumber
numberWithFloat
:
8
.
0
];
[
_circleChart
setStrokeColor
:
_strokeColor
];
[
_circleChart
strokeChart
];
[
self
addSubview
:
_circleChart
];
}
}
-
(
void
)
strokeChart
{
if
(
_lineChart
)
{
[
_lineChart
strokeChart
];
[
_lineChart
setStrokeColor
:
_strokeColor
];
}
else
if
(
_barChart
)
{
[
_barChart
strokeChart
];
[
_barChart
setStrokeColor
:
_strokeColor
];
}
else
if
(
_circleChart
)
{
[
_circleChart
strokeChart
];
[
_circleChart
setStrokeColor
:
_strokeColor
];
}
else
{
[
self
setUpChart
];
}
}
-
(
void
)
userClickedOnLineKeyPoint
:
(
CGPoint
)
point
andPointIndex
:
(
NSInteger
)
index
{
[
_delegate
userClickedOnLineKeyPoint
:
point
andPointIndex
:
index
];
}
-
(
void
)
userClickedOnLinePoint
:
(
CGPoint
)
point
{
[
_delegate
userClickedOnLinePoint
:
point
];
}
@end
PNChartDemo/PNChart/PNCircleChart.m
View file @
a7b298f
...
...
@@ -19,7 +19,9 @@
if
(
self
)
{
_total
=
total
;
_current
=
current
;
_strokeColor
=
PNFreshGreen
;
_lineWidth
=
[
NSNumber
numberWithFloat
:
8
.
0
];
UIBezierPath
*
circlePath
=
[
UIBezierPath
bezierPathWithArcCenter
:
CGPointMake
(
self
.
center
.
x
,
self
.
center
.
y
)
radius
:
self
.
frame
.
size
.
height
*
0
.
5
startAngle
:
DEGREES_TO_RADIANS
(
270
)
endAngle
:
DEGREES_TO_RADIANS
(
270
.
01
)
clockwise
:
NO
];
_circle
=
[
CAShapeLayer
layer
];
...
...
PNChartDemo/PNChart/PNLineChart.m
View file @
a7b298f
...
...
@@ -39,7 +39,6 @@
-
(
void
)
setYValues
:(
NSArray
*
)
yValues
{
_yValues
=
yValues
;
_xLabelWidth
=
(
self
.
frame
.
size
.
width
)
/
[
_yValues
count
];
float
max
=
0
;
for
(
NSString
*
valueString
in
yValues
)
{
...
...
@@ -94,6 +93,8 @@
label
.
text
=
labelText
;
[
self
addSubview
:
label
];
}
}
else
{
_xLabelWidth
=
(
self
.
frame
.
size
.
width
)
/
[
xLabels
count
];
}
}
...
...
Please
register
or
login
to post a comment