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
Antoine Gamond
2014-08-22 14:16:14 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
58d08e8b17781aefd7189d59cc108b2452ddc18c
58d08e8b
1 parent
bc4d7da4
Add font and color customization for xLabel and yLabel in PNLineChart
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
2 deletions
PNChart/PNLineChart.h
PNChart/PNLineChart.m
Podfile.lock
PNChart/PNLineChart.h
View file @
58d08e8
...
...
@@ -33,6 +33,10 @@
@property
(
nonatomic
)
CGFloat
xLabelWidth
;
@property
(
nonatomic
)
UIFont
*
xLabelFont
;
@property
(
nonatomic
)
UIColor
*
xLabelColor
;
@property
(
nonatomic
)
CGFloat
yValueMax
;
@property
(
nonatomic
)
CGFloat
yValueMin
;
...
...
@@ -41,6 +45,10 @@
@property
(
nonatomic
)
CGFloat
yLabelHeight
;
@property
(
nonatomic
)
UIFont
*
yLabelFont
;
@property
(
nonatomic
)
UIColor
*
yLabelColor
;
@property
(
nonatomic
)
CGFloat
chartCavanHeight
;
@property
(
nonatomic
)
CGFloat
chartCavanWidth
;
...
...
PNChart/PNLineChart.m
View file @
58d08e8
...
...
@@ -71,14 +71,17 @@
if
(
yStep
==
0
.
0
)
{
PNChartLabel
*
minLabel
=
[[
PNChartLabel
alloc
]
initWithFrame
:
CGRectMake
(
0
.
0
,
_chartCavanHeight
,
_chartMargin
,
_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
)];
midLabel
.
text
=
[
NSString
stringWithFormat
:
yLabelFormat
,
_yValueMax
];
[
self
setCustomStyleForYLabel
:
midLabel
];
[
self
addSubview
:
midLabel
];
PNChartLabel
*
maxLabel
=
[[
PNChartLabel
alloc
]
initWithFrame
:
CGRectMake
(
0
.
0
,
0
.
0
,
_chartMargin
,
_yLabelHeight
)];
maxLabel
.
text
=
[
NSString
stringWithFormat
:
yLabelFormat
,
_yValueMax
*
2
];
[
self
setCustomStyleForYLabel
:
maxLabel
];
[
self
addSubview
:
maxLabel
];
}
else
{
...
...
@@ -89,6 +92,7 @@
PNChartLabel
*
label
=
[[
PNChartLabel
alloc
]
initWithFrame
:
CGRectMake
(
0
.
0
,
(
_chartCavanHeight
-
index
*
yStepHeight
),
_chartMargin
,
_yLabelHeight
)];
[
label
setTextAlignment
:
NSTextAlignmentRight
];
label
.
text
=
[
NSString
stringWithFormat
:
yLabelFormat
,
_yValueMin
+
(
yStep
*
index
)];
[
self
setCustomStyleForYLabel
:
label
];
[
self
addSubview
:
label
];
index
+=
1
;
num
-=
1
;
...
...
@@ -96,7 +100,6 @@
}
}
-
(
void
)
setXLabels
:(
NSArray
*
)
xLabels
{
_xLabels
=
xLabels
;
...
...
@@ -110,6 +113,7 @@
PNChartLabel
*
label
=
[[
PNChartLabel
alloc
]
initWithFrame
:
CGRectMake
(
2
*
_chartMargin
+
(
index
*
_xLabelWidth
)
-
(
_xLabelWidth
/
2
),
_chartMargin
+
_chartCavanHeight
,
_xLabelWidth
,
_chartMargin
)];
[
label
setTextAlignment
:
NSTextAlignmentCenter
];
label
.
text
=
labelText
;
[
self
setCustomStyleForXLabel
:
label
];
[
self
addSubview
:
label
];
}
}
...
...
@@ -118,6 +122,24 @@
}
}
-
(
void
)
setCustomStyleForXLabel
:(
UILabel
*
)
label
{
if
(
_xLabelFont
)
{
label
.
font
=
_xLabelFont
;
}
if
(
_xLabelColor
)
{
label
.
textColor
=
_xLabelColor
;
}
}
-
(
void
)
setCustomStyleForYLabel
:(
UILabel
*
)
label
{
if
(
_yLabelFont
)
{
label
.
font
=
_yLabelFont
;
}
if
(
_yLabelColor
)
{
label
.
textColor
=
_yLabelColor
;
}
}
-
(
void
)
touchesBegan
:(
NSSet
*
)
touches
withEvent
:(
UIEvent
*
)
event
{
...
...
Podfile.lock
View file @
58d08e8
...
...
@@ -7,4 +7,4 @@ DEPENDENCIES:
SPEC CHECKSUMS:
UICountingLabel: 0a0e9e34bf4690dbd127aaec552d19ed938087a9
COCOAPODS: 0.3
2
.1
COCOAPODS: 0.3
3
.1
...
...
Please
register
or
login
to post a comment