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
Kevin
2015-03-17 02:10:26 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
4b422a97f2137eb1c53606607276a188848bbb55
4b422a97
2 parents
8cf1b7c8
0412e632
Merge pull request #178 from antoninbiret/master
Fix #177
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
22 additions
and
15 deletions
PNChart/PNBarChart.h
PNChart/PNBarChart.m
PNChart/PNColor.h
PNChart/PNColor.m
PNChart/PNLineChartData.h
PNChart/PNLineChartDataItem.h
PNChart/PNPieChartDataItem.h
PNChart/PNPieChartDataItem.m
PNChart/PNScatterChartData.h
PNChart/PNScatterChartDataItem.h
PNChart/PNBarChart.h
View file @
4b422a9
...
...
@@ -11,10 +11,10 @@
#import "PNChartDelegate.h"
#import "PNBar.h"
#define
x
LabelMargin 15
#define
y
LabelMargin 15
#define
y
LabelHeight 11
#define
x
LabelHeight 20
#define
kX
LabelMargin 15
#define
kY
LabelMargin 15
#define
kY
LabelHeight 11
#define
kX
LabelHeight 20
typedef
NSString
*
(
^
PNYLabelFormatter
)(
CGFloat
yLabelValue
);
...
...
PNChart/PNBarChart.m
View file @
4b422a9
...
...
@@ -87,16 +87,16 @@
if
(
_showLabel
)
{
//Add y labels
float
yLabelSectionHeight
=
(
self
.
frame
.
size
.
height
-
_chartMargin
*
2
-
x
LabelHeight
)
/
_yLabelSum
;
float
yLabelSectionHeight
=
(
self
.
frame
.
size
.
height
-
_chartMargin
*
2
-
kX
LabelHeight
)
/
_yLabelSum
;
for
(
int
index
=
0
;
index
<
_yLabelSum
;
index
++
)
{
NSString
*
labelText
=
_yLabelFormatter
((
float
)
_yValueMax
*
(
(
_yLabelSum
-
index
)
/
(
float
)
_yLabelSum
));
PNChartLabel
*
label
=
[[
PNChartLabel
alloc
]
initWithFrame
:
CGRectMake
(
0
,
yLabelSectionHeight
*
index
+
_chartMargin
-
y
LabelHeight
/
2
.
0
,
yLabelSectionHeight
*
index
+
_chartMargin
-
kY
LabelHeight
/
2
.
0
,
_yChartLabelWidth
,
y
LabelHeight
)];
kY
LabelHeight
)];
label
.
font
=
_labelFont
;
label
.
textColor
=
_labelTextColor
;
[
label
setTextAlignment
:
NSTextAlignmentRight
];
...
...
@@ -144,7 +144,7 @@
if
(
labelAddCount
==
_xLabelSkip
)
{
NSString
*
labelText
=
[
_xLabels
[
index
]
description
];
PNChartLabel
*
label
=
[[
PNChartLabel
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
_xLabelWidth
,
x
LabelHeight
)];
PNChartLabel
*
label
=
[[
PNChartLabel
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
_xLabelWidth
,
kX
LabelHeight
)];
label
.
font
=
_labelFont
;
label
.
textColor
=
_labelTextColor
;
[
label
setTextAlignment
:
NSTextAlignmentCenter
];
...
...
@@ -159,7 +159,7 @@
labelXPosition
=
(
index
*
_xLabelWidth
+
_chartMargin
+
_xLabelWidth
/
2
.
0
);
}
label
.
center
=
CGPointMake
(
labelXPosition
,
self
.
frame
.
size
.
height
-
x
LabelHeight
-
_chartMargin
+
label
.
frame
.
size
.
height
/
2
.
0
+
_labelMarginTop
);
self
.
frame
.
size
.
height
-
kX
LabelHeight
-
_chartMargin
+
label
.
frame
.
size
.
height
/
2
.
0
+
_labelMarginTop
);
labelAddCount
=
0
;
[
_xChartLabels
addObject
:
label
];
...
...
@@ -179,7 +179,7 @@
{
//Add bars
CGFloat
chartCavanHeight
=
self
.
frame
.
size
.
height
-
_chartMargin
*
2
-
x
LabelHeight
;
CGFloat
chartCavanHeight
=
self
.
frame
.
size
.
height
-
_chartMargin
*
2
-
kX
LabelHeight
;
NSInteger
index
=
0
;
for
(
NSNumber
*
valueString
in
_yValues
)
{
...
...
@@ -208,7 +208,7 @@
}
bar
=
[[
PNBar
alloc
]
initWithFrame
:
CGRectMake
(
barXPosition
,
//Bar X position
self
.
frame
.
size
.
height
-
chartCavanHeight
-
x
LabelHeight
-
_chartMargin
,
//Bar Y position
self
.
frame
.
size
.
height
-
chartCavanHeight
-
kX
LabelHeight
-
_chartMargin
,
//Bar Y position
barWidth
,
// Bar witdh
chartCavanHeight
)];
//Bar height
...
...
@@ -270,8 +270,8 @@
UIBezierPath
*
progressline
=
[
UIBezierPath
bezierPath
];
[
progressline
moveToPoint
:
CGPointMake
(
_chartMargin
,
self
.
frame
.
size
.
height
-
x
LabelHeight
-
_chartMargin
)];
[
progressline
addLineToPoint
:
CGPointMake
(
self
.
frame
.
size
.
width
-
_chartMargin
,
self
.
frame
.
size
.
height
-
x
LabelHeight
-
_chartMargin
)];
[
progressline
moveToPoint
:
CGPointMake
(
_chartMargin
,
self
.
frame
.
size
.
height
-
kX
LabelHeight
-
_chartMargin
)];
[
progressline
addLineToPoint
:
CGPointMake
(
self
.
frame
.
size
.
width
-
_chartMargin
,
self
.
frame
.
size
.
height
-
kX
LabelHeight
-
_chartMargin
)];
[
progressline
setLineWidth
:
1
.
0
];
[
progressline
setLineCapStyle
:
kCGLineCapSquare
];
...
...
@@ -302,7 +302,7 @@
UIBezierPath
*
progressLeftline
=
[
UIBezierPath
bezierPath
];
[
progressLeftline
moveToPoint
:
CGPointMake
(
_chartMargin
,
self
.
frame
.
size
.
height
-
x
LabelHeight
-
_chartMargin
)];
[
progressLeftline
moveToPoint
:
CGPointMake
(
_chartMargin
,
self
.
frame
.
size
.
height
-
kX
LabelHeight
-
_chartMargin
)];
[
progressLeftline
addLineToPoint
:
CGPointMake
(
_chartMargin
,
_chartMargin
)];
[
progressLeftline
setLineWidth
:
1
.
0
];
...
...
PNChart/PNColor.h
View file @
4b422a9
...
...
@@ -7,6 +7,7 @@
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
/*
* System Versioning Preprocessor Macros
...
...
PNChart/PNColor.m
View file @
4b422a9
...
...
@@ -7,6 +7,7 @@
//
#import "PNColor.h"
#import <UIKit/UIKit.h>
@implementation
PNColor
...
...
PNChart/PNLineChartData.h
View file @
4b422a9
...
...
@@ -4,6 +4,7 @@
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
typedef
NS_ENUM
(
NSUInteger
,
PNLineChartPointStyle
)
{
PNLineChartPointStyleNone
=
0
,
...
...
PNChart/PNLineChartDataItem.h
View file @
4b422a9
...
...
@@ -4,7 +4,7 @@
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface
PNLineChartDataItem
:
NSObject
...
...
PNChart/PNPieChartDataItem.h
View file @
4b422a9
...
...
@@ -7,6 +7,7 @@
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface
PNPieChartDataItem
:
NSObject
...
...
PNChart/PNPieChartDataItem.m
View file @
4b422a9
...
...
@@ -7,6 +7,7 @@
//
#import "PNPieChartDataItem.h"
#import <UIKit/UIKit.h>
@implementation
PNPieChartDataItem
...
...
PNChart/PNScatterChartData.h
View file @
4b422a9
...
...
@@ -7,6 +7,7 @@
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
typedef
NS_ENUM
(
NSUInteger
,
PNScatterChartPointStyle
)
{
PNScatterChartPointStyleCircle
=
0
,
...
...
PNChart/PNScatterChartDataItem.h
View file @
4b422a9
...
...
@@ -7,6 +7,7 @@
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface
PNScatterChartDataItem
:
NSObject
...
...
Please
register
or
login
to post a comment