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-09-06 14:00:10 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
f218644a8202d0276dfe414911235655bba57d5e
f218644a
2 parents
41ac2ff0
f49d2f19
Merge pull request #101 from Antoine4011/custom-style
Label improvements
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
9 deletions
PNChart/PNChartLabel.m
PNChart/PNLineChart.m
PNChart/PNChartLabel.m
View file @
f218644
...
...
@@ -18,10 +18,12 @@
if
(
self
)
{
// Initialization code
[
self
setFont
:[
UIFont
boldSystemFontOfSize
:
11
.
0
f
]];
self
.
backgroundColor
=
[
UIColor
clearColor
];
[
self
setTextAlignment
:
NSTextAlignmentCenter
];
self
.
userInteractionEnabled
=
YES
;
self
.
font
=
[
UIFont
boldSystemFontOfSize
:
11
.
0
f
];
self
.
backgroundColor
=
[
UIColor
clearColor
];
self
.
textAlignment
=
NSTextAlignmentCenter
;
self
.
userInteractionEnabled
=
YES
;
self
.
minimumScaleFactor
=
0
.
8
;
self
.
adjustsFontSizeToFitWidth
=
YES
;
}
return
self
;
...
...
PNChart/PNLineChart.m
View file @
f218644
...
...
@@ -65,17 +65,17 @@
NSString
*
yLabelFormat
=
self
.
yLabelFormat
?
:
@"%1.f"
;
if
(
yStep
==
0
.
0
)
{
PNChartLabel
*
minLabel
=
[[
PNChartLabel
alloc
]
initWithFrame
:
CGRectMake
(
0
.
0
,
_chartCavanHeight
,
_chartMargin
,
_yLabelHeight
)];
PNChartLabel
*
minLabel
=
[[
PNChartLabel
alloc
]
initWithFrame
:
CGRectMake
(
0
.
0
,
(
NSInteger
)
_chartCavanHeight
,
(
NSInteger
)
_chartMargin
,
(
NSInteger
)
_yLabelHeight
)];
minLabel
.
text
=
[
NSString
stringWithFormat
:
yLabelFormat
,
0
.
0
];
[
self
setCustomStyleForYLabel
:
minLabel
];
[
self
addSubview
:
minLabel
];
PNChartLabel
*
midLabel
=
[[
PNChartLabel
alloc
]
initWithFrame
:
CGRectMake
(
0
.
0
,
_chartCavanHeight
/
2
,
_chartMargin
,
_yLabelHeight
)];
PNChartLabel
*
midLabel
=
[[
PNChartLabel
alloc
]
initWithFrame
:
CGRectMake
(
0
.
0
,
(
NSInteger
)(
_chartCavanHeight
/
2
),
(
NSInteger
)
_chartMargin
,
(
NSInteger
)
_yLabelHeight
)];
midLabel
.
text
=
[
NSString
stringWithFormat
:
yLabelFormat
,
_yValueMax
];
[
self
setCustomStyleForYLabel
:
midLabel
];
[
self
addSubview
:
midLabel
];
PNChartLabel
*
maxLabel
=
[[
PNChartLabel
alloc
]
initWithFrame
:
CGRectMake
(
0
.
0
,
0
.
0
,
_chartMargin
,
_yLabelHeight
)];
PNChartLabel
*
maxLabel
=
[[
PNChartLabel
alloc
]
initWithFrame
:
CGRectMake
(
0
.
0
,
0
.
0
,
(
NSInteger
)
_chartMargin
,
(
NSInteger
)
_yLabelHeight
)];
maxLabel
.
text
=
[
NSString
stringWithFormat
:
yLabelFormat
,
_yValueMax
*
2
];
[
self
setCustomStyleForYLabel
:
maxLabel
];
[
self
addSubview
:
maxLabel
];
...
...
@@ -86,7 +86,7 @@
while
(
num
>
0
)
{
PNChartLabel
*
label
=
[[
PNChartLabel
alloc
]
initWithFrame
:
CGRectMake
(
0
.
0
,
(
_chartCavanHeight
-
index
*
yStepHeight
),
_chartMargin
,
_yLabelHeight
)];
PNChartLabel
*
label
=
[[
PNChartLabel
alloc
]
initWithFrame
:
CGRectMake
(
0
.
0
,
(
NSInteger
)(
_chartCavanHeight
-
index
*
yStepHeight
),
(
NSInteger
)
_chartMargin
,
(
NSInteger
)
_yLabelHeight
)];
[
label
setTextAlignment
:
NSTextAlignmentRight
];
label
.
text
=
[
NSString
stringWithFormat
:
yLabelFormat
,
_yValueMin
+
(
yStep
*
index
)];
[
self
setCustomStyleForYLabel
:
label
];
...
...
@@ -124,7 +124,7 @@
NSInteger
x
=
2
*
_chartMargin
+
(
index
*
_xLabelWidth
)
-
(
_xLabelWidth
/
2
);
NSInteger
y
=
_chartMargin
+
_chartCavanHeight
;
PNChartLabel
*
label
=
[[
PNChartLabel
alloc
]
initWithFrame
:
CGRectMake
(
x
,
y
,
_xLabelWidth
,
_chartMargin
)];
PNChartLabel
*
label
=
[[
PNChartLabel
alloc
]
initWithFrame
:
CGRectMake
(
x
,
y
,
(
NSInteger
)
_xLabelWidth
,
(
NSInteger
)
_chartMargin
)];
[
label
setTextAlignment
:
NSTextAlignmentCenter
];
label
.
text
=
labelText
;
[
self
setCustomStyleForXLabel
:
label
];
...
...
@@ -142,6 +142,7 @@
if
(
_xLabelColor
)
{
label
.
textColor
=
_xLabelColor
;
}
}
-
(
void
)
setCustomStyleForYLabel
:(
UILabel
*
)
label
...
...
Please
register
or
login
to post a comment