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
MrWooJ
2014-12-01 15:35:03 +0330
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
849a76d596520efde084f5332de7ae6f058d6a46
849a76d5
1 parent
9298fb41
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 @
849a76d
...
...
@@ -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 @
849a76d
...
...
@@ -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 @
849a76d
...
...
@@ -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