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
Nuno Dias
2014-05-11 21:29:43 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7526b765bccec507f93e0e9cb59f8ff9ab1f17e5
7526b765
1 parent
6292f427
Added yLabelFormat property to define the y axis label formatting.
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
2 deletions
PNChart/PNLineChart/PNLineChart.h
PNChart/PNLineChart/PNLineChart.m
PNChartDemo/PCChartsTableViewController.m
PNChart/PNLineChart/PNLineChart.h
View file @
7526b76
...
...
@@ -63,4 +63,9 @@
@property
(
nonatomic
,
strong
)
NSString
*
xUnit
;
@property
(
nonatomic
,
strong
)
NSString
*
yUnit
;
/**
* String formatter for float values in y labels. If not set, defaults to @"%1.f"
*/
@property
(
nonatomic
,
strong
)
NSString
*
yLabelFormat
;
@end
...
...
PNChart/PNLineChart/PNLineChart.m
View file @
7526b76
...
...
@@ -72,7 +72,8 @@
while
(
num
>
0
)
{
PNChartLabel
*
label
=
[[
PNChartLabel
alloc
]
initWithFrame
:
CGRectMake
(
0
.
0
,
(
_chartCavanHeight
-
index
*
yStepHeight
),
_chartMargin
,
_yLabelHeight
)];
[
label
setTextAlignment
:
NSTextAlignmentRight
];
label
.
text
=
[
NSString
stringWithFormat
:
@"%1.f"
,
_yValueMin
+
(
yStep
*
index
)];
NSString
*
yLabelFormat
=
self
.
yLabelFormat
?
self
.
yLabelFormat
:
@"%1.f"
;
label
.
text
=
[
NSString
stringWithFormat
:
yLabelFormat
,
_yValueMin
+
(
yStep
*
index
)];
[
self
addSubview
:
label
];
index
+=
1
;
num
-=
1
;
...
...
@@ -368,7 +369,7 @@
_yLabelNum
=
5
.
0
;
_yLabelHeight
=
[[[[
PNChartLabel
alloc
]
init
]
font
]
pointSize
];
_chartMargin
=
3
0
;
_chartMargin
=
4
0
;
_chartCavanWidth
=
self
.
frame
.
size
.
width
-
_chartMargin
*
2
;
_chartCavanHeight
=
self
.
frame
.
size
.
height
-
_chartMargin
*
2
;
...
...
PNChartDemo/PCChartsTableViewController.m
View file @
7526b76
...
...
@@ -61,6 +61,7 @@
lineChartLabel
.
textAlignment
=
NSTextAlignmentCenter
;
PNLineChart
*
lineChart
=
[[
PNLineChart
alloc
]
initWithFrame
:
CGRectMake
(
0
,
135
.
0
,
SCREEN_WIDTH
,
200
.
0
)];
lineChart
.
yLabelFormat
=
@"%1.1f"
;
lineChart
.
backgroundColor
=
[
UIColor
clearColor
];
[
lineChart
setXLabels
:@[
@"SEP 1"
,
@"SEP 2"
,
@"SEP 3"
,
@"SEP 4"
,
@"SEP 5"
,
@"SEP 6"
,
@"SEP 7"
]];
...
...
Please
register
or
login
to post a comment