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
olunx
2015-03-12 18:28:16 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f0ffd9e5178f0d6287ed7a2039b3323fd9db882e
f0ffd9e5
1 parent
fb079043
Add options for chart legend font style.
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
9 deletions
PNChart/PNGenericChart.h
PNChart/PNLineChart.m
PNChart/PNPieChart.m
PNChartDemo/PCChartViewController.m
PNChart/PNGenericChart.h
View file @
f0ffd9e
...
...
@@ -25,7 +25,8 @@ typedef NS_ENUM(NSUInteger, PNLegendItemStyle) {
@property
(
assign
,
nonatomic
)
BOOL
hasLegend
;
@property
(
assign
,
nonatomic
)
PNLegendPosition
legendPosition
;
@property
(
assign
,
nonatomic
)
PNLegendItemStyle
legendStyle
;
@property
(
assign
,
nonatomic
)
CGFloat
legendFontSize
;
@property
(
assign
,
nonatomic
)
UIFont
*
legendFont
;
@property
(
assign
,
nonatomic
)
UIColor
*
legendFontColor
;
/**
* returns the Legend View, or nil if no chart data is present.
...
...
PNChart/PNLineChart.m
View file @
f0ffd9e
...
...
@@ -821,13 +821,13 @@
* 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
;
for
(
PNLineChartData
*
pdata
in
self
.
chartData
)
{
/* 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 */
...
...
@@ -869,7 +869,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
;
x
+=
self
.
legendStyle
==
PNLegendItemStyleStacked
?
0
:
labelsize
.
width
+
legendLineWidth
;
...
...
PNChart/PNPieChart.m
View file @
f0ffd9e
...
...
@@ -277,13 +277,13 @@
* 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
;
for
(
PNPieChartDataItem
*
pdata
in
self
.
items
)
{
/* 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
]];
// Add inflexion type
...
...
@@ -293,7 +293,8 @@
UILabel
*
label
=
[[
UILabel
alloc
]
initWithFrame
:
CGRectMake
(
x
+
legendCircle
,
y
,
maxLabelWidth
,
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
;
x
+=
self
.
legendStyle
==
PNLegendItemStyleStacked
?
0
:
labelsize
.
width
+
legendCircle
;
...
...
PNChartDemo/PCChartViewController.m
View file @
f0ffd9e
...
...
@@ -80,7 +80,8 @@
[
self
.
view
addSubview
:
self
.
lineChart
];
self
.
lineChart
.
legendStyle
=
PNLegendItemStyleStacked
;
self
.
lineChart
.
legendFontSize
=
12
.
0
;
self
.
lineChart
.
legendFont
=
[
UIFont
boldSystemFontOfSize
:
12
.
0
f
];
self
.
lineChart
.
legendFontColor
=
[
UIColor
redColor
];
UIView
*
legend
=
[
self
.
lineChart
getLegendWithMaxWidth
:
200
];
[
legend
setFrame
:
CGRectMake
(
100
,
400
,
legend
.
frame
.
size
.
width
,
legend
.
frame
.
size
.
width
)];
...
...
@@ -153,7 +154,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
(
100
,
400
,
legend
.
frame
.
size
.
width
,
legend
.
frame
.
size
.
width
)];
...
...
Please
register
or
login
to post a comment