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
dullgrass
2015-05-15 14:10:25 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
13f1024f998ea608ca274b1ae0ea644aa4939ff8
13f1024f
1 parent
7c46ed22
FIXBUG: BarChart Show Wrong Numbers
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
1 deletions
PNChart/PNBarChart.m
PNChart/PNBarChart.m
View file @
13f1024
...
...
@@ -64,7 +64,7 @@
_yChartLabelWidth
=
18
;
_rotateForXAxisText
=
false
;
}
/*
- (void)setYValues:(NSArray *)yValues
{
_yValues = yValues;
...
...
@@ -147,6 +147,53 @@
}
}
}
*/
-
(
void
)
setYValues
:
(
NSArray
*
)
yValues
{
_yValues
=
yValues
;
if
(
_showLabel
)
{
[
self
__addYCoordinateLabelsValues
];
}
}
#pragma mark - Private Method
-
(
void
)
__addYCoordinateLabelsValues
{
[
self
viewCleanupForCollection
:
_yChartLabels
];
NSArray
*
yAxisValues
=
_yLabels
?
_yLabels
:
_yValues
;
if
(
_yMaxValue
)
{
_yValueMax
=
_yMaxValue
;
}
else
{
[
self
getYValueMax
:
yAxisValues
];
}
_yLabelSum
=
yAxisValues
.
count
;
(
_yLabelSum
%
2
==
0
)
?
_yLabelSum
:
_yLabelSum
++
;
float
sectionHeight
=
(
self
.
frame
.
size
.
height
-
_chartMargin
*
2
-
kXLabelHeight
)
/
_yLabelSum
;
for
(
int
i
=
0
;
i
<
_yLabelSum
;
i
++
)
{
NSString
*
labelText
;
if
(
_yLabels
)
{
float
yAsixValue
=
[
_yLabels
[
_yLabels
.
count
-
i
-
1
]
floatValue
];
labelText
=
_yLabelFormatter
(
yAsixValue
);
}
else
{
labelText
=
_yLabelFormatter
((
float
)
_yValueMax
*
(
(
_yLabelSum
-
i
)
/
(
float
)
_yLabelSum
));
}
CGRect
frame
=
(
CGRect
){
0
,
sectionHeight
*
i
+
_chartMargin
-
kYLabelHeight
/
2
.
0
,
_yChartLabelWidth
,
kYLabelHeight
};
PNChartLabel
*
label
=
[[
PNChartLabel
alloc
]
initWithFrame
:
frame
];
label
.
font
=
_labelFont
;
label
.
textColor
=
_labelTextColor
;
[
label
setTextAlignment
:
NSTextAlignmentRight
];
label
.
text
=
labelText
;
[
self
addSubview
:
label
];
[
_yChartLabels
addObject
:
label
];
}
}
-
(
void
)
updateChartData
:
(
NSArray
*
)
data
{
self
.
yValues
=
data
;
...
...
Please
register
or
login
to post a comment