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 08:50:15 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a2dc6a6d335846f4ef22d518073c762a188d5e8a
a2dc6a6d
1 parent
4fe91085
adding legend
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
PNChart/PNPieChart.m
PNChart/PNPieChart.m
View file @
a2dc6a6
...
...
@@ -238,7 +238,11 @@
}
/* This is a small circle that refers to the chart data */
CGFloat
legendCircle
=
10
;
CGFloat
legendCircle
=
16
;
CGFloat
hSpacing
=
0
;
CGFloat
beforeLabel
=
legendCircle
+
hSpacing
;
/* x and y are the coordinates of the starting point of each legend item */
CGFloat
x
=
0
;
...
...
@@ -252,7 +256,7 @@
/* Determine the max width of each legend item */
CGFloat
maxLabelWidth
=
self
.
legendStyle
==
PNLegendItemStyleStacked
?
(
mWidth
-
legendCircle
)
:
(
mWidth
/
[
self
.
items
count
]
-
legendCircle
);
CGFloat
maxLabelWidth
=
self
.
legendStyle
==
PNLegendItemStyleStacked
?
(
mWidth
-
beforeLabel
)
:
(
mWidth
/
[
self
.
items
count
]
-
beforeLabel
);
/* this is used when labels wrap text and the line
* should be in the middle of the first row */
...
...
@@ -268,20 +272,20 @@
// Add inflexion type
[
legendViews
addObject
:[
self
drawInflexion
:
legendCircle
*
.
8
[
legendViews
addObject
:[
self
drawInflexion
:
legendCircle
*
.
6
center
:
CGPointMake
(
x
+
legendCircle
/
2
,
y
+
singleRowHeight
/
2
)
andColor
:
pdata
.
color
]];
UILabel
*
label
=
[[
UILabel
alloc
]
initWithFrame
:
CGRectMake
(
x
+
legendCircle
,
y
,
maxLabelWidth
,
labelsize
.
height
)];
UILabel
*
label
=
[[
UILabel
alloc
]
initWithFrame
:
CGRectMake
(
x
+
beforeLabel
,
y
,
maxLabelWidth
,
labelsize
.
height
)];
label
.
text
=
pdata
.
textDescription
;
label
.
font
=
[
UIFont
systemFontOfSize
:
self
.
legendFontSize
];
label
.
lineBreakMode
=
NSLineBreakByWordWrapping
;
label
.
numberOfLines
=
0
;
x
+=
self
.
legendStyle
==
PNLegendItemStyleStacked
?
0
:
labelsize
.
width
+
legendCircle
;
x
+=
self
.
legendStyle
==
PNLegendItemStyleStacked
?
0
:
labelsize
.
width
+
beforeLabel
;
y
+=
self
.
legendStyle
==
PNLegendItemStyleStacked
?
labelsize
.
height
:
0
;
totalWidth
=
self
.
legendStyle
==
PNLegendItemStyleStacked
?
fmaxf
(
totalWidth
,
labelsize
.
width
+
legendCircle
)
:
totalWidth
+
labelsize
.
width
+
legendCircle
;
totalHeight
=
self
.
legendStyle
==
PNLegendItemStyleS
tacked
?
fmaxf
(
totalHeight
,
labelsize
.
height
)
:
totalHeight
+
labelsize
.
height
;
totalWidth
=
self
.
legendStyle
==
PNLegendItemStyleStacked
?
fmaxf
(
totalWidth
,
labelsize
.
width
+
beforeLabel
)
:
totalWidth
+
labelsize
.
width
+
beforeLabel
;
totalHeight
=
self
.
legendStyle
==
PNLegendItemStyleS
erial
?
fmaxf
(
totalHeight
,
labelsize
.
height
)
:
totalHeight
+
labelsize
.
height
;
[
legendViews
addObject
:
label
];
}
...
...
Please
register
or
login
to post a comment