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
andi
2015-03-04 18:48:55 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8a7628f05602a9b8e7757a85e78c2d3ad4ff1a93
8a7628f0
1 parent
c5a041d7
rotation management
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
8 deletions
PNChart/PNPieChart.m
PNChart/PNPieChart.m
View file @
8a7628f
...
...
@@ -273,10 +273,13 @@
NSMutableArray
*
legendViews
=
[[
NSMutableArray
alloc
]
init
];
NSUInteger
numLabelsPerRow
=
ceil
((
float
)[
self
.
items
count
]
/
self
.
labelRowsInSerialMode
);
/* Determine the max width of each legend item */
CGFloat
maxLabelWidth
=
self
.
legendStyle
==
PNLegendItemStyleStacked
?
(
mWidth
-
beforeLabel
)
:
(
mWidth
/
numLabelsPerRow
-
beforeLabel
);
CGFloat
maxLabelWidth
;
if
(
self
.
legendStyle
==
PNLegendItemStyleStacked
)
{
maxLabelWidth
=
mWidth
-
beforeLabel
;
}
else
{
maxLabelWidth
=
MAXFLOAT
;
}
/* this is used when labels wrap text and the line
* should be in the middle of the first row */
...
...
@@ -285,6 +288,7 @@
font
:
[
UIFont
systemFontOfSize
:
self
.
legendFontSize
]].
height
;
NSUInteger
counter
=
0
;
NSUInteger
rowWidth
=
0
;
NSUInteger
rowMaxHeight
=
0
;
for
(
PNPieChartDataItem
*
pdata
in
self
.
items
)
{
...
...
@@ -293,20 +297,20 @@
withWidth
:
maxLabelWidth
font
:
[
UIFont
systemFontOfSize
:
self
.
legendFontSize
]];
if
(
counter
!=
0
&&
counter
%
numLabelsPerRow
==
0
)
{
if
(
rowWidth
+
labelsize
.
width
>
mWidth
)
{
rowWidth
=
0
;
x
=
0
;
y
+=
rowMaxHeight
;
rowMaxHeight
=
0
;
}
rowWidth
+=
labelsize
.
width
;
// Add inflexion type
[
legendViews
addObject
:[
self
drawInflexion
:
legendCircle
*
.
6
center
:
CGPointMake
(
x
+
legendCircle
/
2
,
y
+
singleRowHeight
/
2
)
andColor
:
pdata
.
color
]];
UILabel
*
label
=
[[
UILabel
alloc
]
initWithFrame
:
CGRectMake
(
x
+
beforeLabel
,
y
,
maxLabelW
idth
,
labelsize
.
height
)];
UILabel
*
label
=
[[
UILabel
alloc
]
initWithFrame
:
CGRectMake
(
x
+
beforeLabel
,
y
,
labelsize
.
w
idth
,
labelsize
.
height
)];
label
.
text
=
pdata
.
textDescription
;
label
.
font
=
[
UIFont
systemFontOfSize
:
self
.
legendFontSize
];
label
.
lineBreakMode
=
NSLineBreakByWordWrapping
;
...
...
@@ -314,7 +318,7 @@
rowMaxHeight
=
fmaxf
(
rowMaxHeight
,
labelsize
.
height
);
x
+=
self
.
legendStyle
==
PNLegendItemStyleStacked
?
0
:
maxLabelW
idth
+
beforeLabel
;
x
+=
self
.
legendStyle
==
PNLegendItemStyleStacked
?
0
:
labelsize
.
w
idth
+
beforeLabel
;
y
+=
self
.
legendStyle
==
PNLegendItemStyleStacked
?
labelsize
.
height
:
0
;
...
...
Please
register
or
login
to post a comment