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
2015-03-17 02:10:44 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
c9f5525b5861d6e3b295b3a90bbeedc19ce264d8
c9f5525b
2 parents
4b422a97
6a33211d
Merge pull request #175 from lunzii/master
Add options for chart legend font style.
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
10 deletions
PNChart/PNGenericChart.h
PNChart/PNLineChart.m
PNChart/PNPieChart.m
PNChartDemo/PCChartViewController.m
PNChart/PNGenericChart.h
View file @
c9f5525
...
...
@@ -25,8 +25,10 @@ typedef NS_ENUM(NSUInteger, PNLegendItemStyle) {
@property
(
assign
,
nonatomic
)
BOOL
hasLegend
;
@property
(
assign
,
nonatomic
)
PNLegendPosition
legendPosition
;
@property
(
assign
,
nonatomic
)
PNLegendItemStyle
legendStyle
;
@property
(
assign
,
nonatomic
)
UIFont
*
legendFont
;
@property
(
assign
,
nonatomic
)
UIColor
*
legendFontColor
;
@property
(
assign
,
nonatomic
)
NSUInteger
labelRowsInSerialMode
;
@property
(
assign
,
nonatomic
)
CGFloat
legendFontSize
;
/**
* returns the Legend View, or nil if no chart data is present.
...
...
PNChart/PNLineChart.m
View file @
c9f5525
...
...
@@ -818,7 +818,7 @@
* should be in the middle of the first row */
CGFloat
singleRowHeight
=
[
PNLineChart
sizeOfString
:
@"Test"
withWidth
:
MAXFLOAT
font
:
[
UIFont
systemFontOfSize
:
self
.
legendFontSize
]].
height
;
font
:
self
.
legendFont
?
self
.
legendFont
:
[
UIFont
systemFontOfSize
:
12
.
0
f
]].
height
;
NSUInteger
counter
=
0
;
NSUInteger
rowMaxHeight
=
0
;
...
...
@@ -827,7 +827,7 @@
/* Expected label size*/
CGSize
labelsize
=
[
PNLineChart
sizeOfString
:
pdata
.
dataTitle
withWidth
:
maxLabelWidth
font
:
[
UIFont
systemFontOfSize
:
self
.
legendFontSize
]];
font
:
self
.
legendFont
?
self
.
legendFont
:
[
UIFont
systemFontOfSize
:
12
.
0
f
]];
/* draw lines */
...
...
@@ -874,7 +874,8 @@
UILabel
*
label
=
[[
UILabel
alloc
]
initWithFrame
:
CGRectMake
(
x
+
legendLineWidth
,
y
,
maxLabelWidth
,
labelsize
.
height
)];
label
.
text
=
pdata
.
dataTitle
;
label
.
font
=
[
UIFont
systemFontOfSize
:
self
.
legendFontSize
];
label
.
textColor
=
self
.
legendFontColor
?
self
.
legendFontColor
:
[
UIColor
blackColor
];
label
.
font
=
self
.
legendFont
?
self
.
legendFont
:
[
UIFont
systemFontOfSize
:
12
.
0
f
];
label
.
lineBreakMode
=
NSLineBreakByWordWrapping
;
label
.
numberOfLines
=
0
;
...
...
PNChart/PNPieChart.m
View file @
c9f5525
...
...
@@ -348,7 +348,7 @@
* should be in the middle of the first row */
CGFloat
singleRowHeight
=
[
PNLineChart
sizeOfString
:
@"Test"
withWidth
:
MAXFLOAT
font
:
[
UIFont
systemFontOfSize
:
self
.
legendFontSize
]].
height
;
font
:
self
.
legendFont
?
self
.
legendFont
:
[
UIFont
systemFontOfSize
:
12
.
0
f
]].
height
;
NSUInteger
counter
=
0
;
NSUInteger
rowWidth
=
0
;
...
...
@@ -358,7 +358,7 @@
/* Expected label size*/
CGSize
labelsize
=
[
PNLineChart
sizeOfString
:
pdata
.
textDescription
withWidth
:
maxLabelWidth
font
:
[
UIFont
systemFontOfSize
:
self
.
legendFontSize
]];
font
:
self
.
legendFont
?
self
.
legendFont
:
[
UIFont
systemFontOfSize
:
12
.
0
f
]];
if
((
rowWidth
+
labelsize
.
width
+
beforeLabel
>
mWidth
)
&&
(
self
.
legendStyle
==
PNLegendItemStyleSerial
))
{
rowWidth
=
0
;
...
...
@@ -376,7 +376,8 @@
UILabel
*
label
=
[[
UILabel
alloc
]
initWithFrame
:
CGRectMake
(
x
+
beforeLabel
,
y
,
labelsize
.
width
,
labelsize
.
height
)];
label
.
text
=
pdata
.
textDescription
;
label
.
font
=
[
UIFont
systemFontOfSize
:
self
.
legendFontSize
];
label
.
textColor
=
self
.
legendFontColor
?
self
.
legendFontColor
:
[
UIColor
blackColor
];
label
.
font
=
self
.
legendFont
?
self
.
legendFont
:
[
UIFont
systemFontOfSize
:
12
.
0
f
];
label
.
lineBreakMode
=
NSLineBreakByWordWrapping
;
label
.
numberOfLines
=
0
;
...
...
PNChartDemo/PCChartViewController.m
View file @
c9f5525
...
...
@@ -80,8 +80,10 @@
[
self
.
view
addSubview
:
self
.
lineChart
];
self
.
lineChart
.
legendStyle
=
PNLegendItemStyleSerial
;
self
.
lineChart
.
legendFontSize
=
12
.
0
;
self
.
lineChart
.
legendStyle
=
PNLegendItemStyleStacked
;
self
.
lineChart
.
legendFont
=
[
UIFont
boldSystemFontOfSize
:
12
.
0
f
];
self
.
lineChart
.
legendFontColor
=
[
UIColor
redColor
];
UIView
*
legend
=
[
self
.
lineChart
getLegendWithMaxWidth
:
320
];
[
legend
setFrame
:
CGRectMake
(
30
,
340
,
legend
.
frame
.
size
.
width
,
legend
.
frame
.
size
.
width
)];
...
...
@@ -154,7 +156,7 @@
self
.
pieChart
.
legendStyle
=
PNLegendItemStyleStacked
;
self
.
pieChart
.
legendFont
Size
=
12
.
0
;
self
.
pieChart
.
legendFont
=
[
UIFont
boldSystemFontOfSize
:
12
.
0
f
]
;
UIView
*
legend
=
[
self
.
pieChart
getLegendWithMaxWidth
:
200
];
[
legend
setFrame
:
CGRectMake
(
130
,
350
,
legend
.
frame
.
size
.
width
,
legend
.
frame
.
size
.
height
)];
...
...
Please
register
or
login
to post a comment