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
2014-12-02 17:47:32 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
210672e86dd06a00e38481b9ca20651ccca5a768
210672e8
2 parents
3f6e0218
849a76d5
Merge pull request #118 from MrWooJ/fixing-Issue#104
fixing issue #104
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
2 deletions
PNChart/PNBarChart.h
PNChart/PNBarChart.m
PNChartDemo/PCChartsTableViewController.m
PNChart/PNBarChart.h
View file @
210672e
...
...
@@ -88,6 +88,9 @@ typedef NSString *(^PNYLabelFormatter)(CGFloat yLabelValue);
/** 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
,
retain
)
id
<
PNChartDelegate
>
delegate
;
@end
...
...
PNChart/PNBarChart.m
View file @
210672e
...
...
@@ -41,6 +41,7 @@
_barRadius
=
2
.
0
;
_showChartBorder
=
NO
;
_yChartLabelWidth
=
18
;
_rotateForXAxisText
=
false
;
}
return
self
;
...
...
@@ -106,8 +107,14 @@
[
label
setTextAlignment
:
NSTextAlignmentCenter
];
label
.
text
=
labelText
;
[
label
sizeToFit
];
CGFloat
labelXPosition
=
(
index
*
_xLabelWidth
+
_chartMargin
+
_xLabelWidth
/
2
.
0
);
CGFloat
labelXPosition
;
if
(
_rotateForXAxisText
){
label
.
transform
=
CGAffineTransformMakeRotation
(
M_PI
/
4
);
labelXPosition
=
(
index
*
_xLabelWidth
+
_chartMargin
+
_xLabelWidth
/
1
.
5
);
}
else
{
labelXPosition
=
(
index
*
_xLabelWidth
+
_chartMargin
+
_xLabelWidth
/
2
.
0
);
}
label
.
center
=
CGPointMake
(
labelXPosition
,
self
.
frame
.
size
.
height
-
xLabelHeight
-
_chartMargin
+
label
.
frame
.
size
.
height
/
2
.
0
+
_labelMarginTop
);
labelAddCount
=
0
;
...
...
PNChartDemo/PCChartsTableViewController.m
View file @
210672e
...
...
@@ -84,6 +84,7 @@
};
self
.
barChart
.
labelMarginTop
=
5
.
0
;
[
self
.
barChart
setXLabels
:@[
@"SEP 1"
,
@"SEP 2"
,
@"SEP 3"
,
@"SEP 4"
,
@"SEP 5"
,
@"SEP 6"
,
@"SEP 7"
]];
self
.
barChart
.
rotateForXAxisText
=
true
;
[
self
.
barChart
setYValues
:@[
@1
,
@24
,
@12
,
@18
,
@30
,
@10
,
@21
]];
[
self
.
barChart
setStrokeColors
:@[
PNGreen
,
PNGreen
,
PNRed
,
PNGreen
,
PNGreen
,
PNYellow
,
PNGreen
]];
// Adding gradient
...
...
Please
register
or
login
to post a comment