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
Orlando Aleman Ortiz
2014-04-21 16:00:09 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a72813668a5f6001945205be2745c1c643a98b04
a7281366
1 parent
b60d5a45
Macro based distances
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
12 deletions
PNChart/PNBarChart.h
PNChart/PNBarChart.m
PNChart/PNBarChart.h
View file @
a728136
...
...
@@ -12,6 +12,7 @@
#define xLabelMargin 15
#define yLabelMargin 15
#define yLabelHeight 11
#define xLabelHeight 20
@interface
PNBarChart
:
UIView
...
...
PNChart/PNBarChart.m
View file @
a728136
...
...
@@ -33,7 +33,7 @@
_labels
=
[
NSMutableArray
array
];
_bars
=
[
NSMutableArray
array
];
}
return
self
;
}
...
...
@@ -41,7 +41,7 @@
{
_yValues
=
yValues
;
[
self
setYLabels
:
yValues
];
_xLabelWidth
=
(
self
.
frame
.
size
.
width
-
chartMargin
*
2
)
/
[
_yValues
count
];
}
...
...
@@ -53,21 +53,21 @@
if
(
value
>
max
)
{
max
=
value
;
}
}
//Min value for Y label
if
(
max
<
5
)
{
max
=
5
;
}
_yValueMax
=
(
int
)
max
;
}
-
(
void
)
setXLabels
:(
NSArray
*
)
xLabels
{
_xLabels
=
xLabels
;
if
(
_showLabel
)
{
_xLabelWidth
=
(
self
.
frame
.
size
.
width
-
chartMargin
*
2
)
/
[
xLabels
count
];
}
...
...
@@ -75,7 +75,7 @@
-
(
void
)
setStrokeColor
:(
UIColor
*
)
strokeColor
{
_strokeColor
=
strokeColor
;
_strokeColor
=
strokeColor
;
}
-
(
void
)
strokeChart
...
...
@@ -85,7 +85,7 @@
for
(
int
index
=
0
;
index
<
_xLabels
.
count
;
index
++
)
{
NSString
*
labelText
=
_xLabels
[
index
];
PNChartLabel
*
label
=
[[
PNChartLabel
alloc
]
initWithFrame
:
CGRectMake
((
index
*
_xLabelWidth
+
chartMargin
),
self
.
frame
.
size
.
height
-
30
.
0
,
_xLabelWidth
,
20
.
0
)];
PNChartLabel
*
label
=
[[
PNChartLabel
alloc
]
initWithFrame
:
CGRectMake
((
index
*
_xLabelWidth
+
chartMargin
),
self
.
frame
.
size
.
height
-
xLabelHeight
-
chartMargin
,
_xLabelWidth
,
xLabelHeight
)];
[
label
setTextAlignment
:
NSTextAlignmentCenter
];
label
.
text
=
labelText
;
[
_labels
addObject
:
label
];
...
...
@@ -95,16 +95,16 @@
[
self
viewCleanupForCollection
:
_bars
];
CGFloat
chartCavanHeight
=
self
.
frame
.
size
.
height
-
chartMargin
*
2
-
40
.
0
;
CGFloat
chartCavanHeight
=
self
.
frame
.
size
.
height
-
chartMargin
*
2
-
xLabelHeight
*
2
;
NSInteger
index
=
0
;
for
(
NSString
*
valueString
in
_yValues
)
{
float
value
=
[
valueString
floatValue
];
float
grade
=
(
float
)
value
/
(
float
)
_yValueMax
;
PNBar
*
bar
;
if
(
_showLabel
)
{
bar
=
[[
PNBar
alloc
]
initWithFrame
:
CGRectMake
((
index
*
_xLabelWidth
+
chartMargin
+
_xLabelWidth
*
0
.
25
),
self
.
frame
.
size
.
height
-
chartCavanHeight
-
30
.
0
,
_xLabelWidth
*
0
.
5
,
chartCavanHeight
)];
bar
=
[[
PNBar
alloc
]
initWithFrame
:
CGRectMake
((
index
*
_xLabelWidth
+
chartMargin
+
_xLabelWidth
*
0
.
25
),
self
.
frame
.
size
.
height
-
chartCavanHeight
-
xLabelHeight
-
chartMargin
,
_xLabelWidth
*
0
.
5
,
chartCavanHeight
)];
}
else
{
...
...
@@ -115,7 +115,7 @@
bar
.
grade
=
grade
;
[
_bars
addObject
:
bar
];
[
self
addSubview
:
bar
];
index
+=
1
;
}
}
...
...
Please
register
or
login
to post a comment