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
kevinzhow
2015-08-24 12:19:19 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
e593cb9fb3c5b98abd40f70ce995fc2e725ac09d
e593cb9f
2 parents
2f6dcd95
eacadafc
Merge branch 'openhood-independant-margins-bar-chart'
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
4 deletions
PNChart/PNBarChart.h
PNChart/PNBarChart.m
PNChartDemo/PCChartViewController.m
PNChart/PNBarChart.h
View file @
e593cb9
...
...
@@ -52,7 +52,10 @@ typedef NSString *(^PNYLabelFormatter)(CGFloat yLabelValue);
/** Suffix to y label values, none if unset. */
@property
(
nonatomic
)
NSString
*
yLabelSuffix
;
@property
(
nonatomic
)
CGFloat
chartMargin
;
@property
(
nonatomic
)
CGFloat
chartMarginLeft
;
@property
(
nonatomic
)
CGFloat
chartMarginRight
;
@property
(
nonatomic
)
CGFloat
chartMarginTop
;
@property
(
nonatomic
)
CGFloat
chartMarginBottom
;
/** Controls whether labels should be displayed. */
@property
(
nonatomic
)
BOOL
showLabel
;
...
...
PNChart/PNBarChart.m
View file @
e593cb9
This diff is collapsed. Click to expand it.
PNChartDemo/PCChartViewController.m
View file @
e593cb9
...
...
@@ -91,20 +91,34 @@
}
else
if
([
self
.
title
isEqualToString
:
@"Bar Chart"
])
{
static
NSNumberFormatter
*
barChartFormatter
;
if
(
!
barChartFormatter
){
barChartFormatter
=
[[
NSNumberFormatter
alloc
]
init
];
barChartFormatter
.
numberStyle
=
NSNumberFormatterCurrencyStyle
;
barChartFormatter
.
allowsFloats
=
NO
;
barChartFormatter
.
maximumFractionDigits
=
0
;
}
self
.
titleLabel
.
text
=
@"Bar Chart"
;
self
.
barChart
=
[[
PNBarChart
alloc
]
initWithFrame
:
CGRectMake
(
0
,
135
.
0
,
SCREEN_WIDTH
,
200
.
0
)];
// self.barChart.showLabel = NO;
self
.
barChart
.
backgroundColor
=
[
UIColor
clearColor
];
self
.
barChart
.
yLabelFormatter
=
^
(
CGFloat
yValue
){
CGFloat
yValueParsed
=
yValue
;
NSString
*
labelText
=
[
NSString
stringWithFormat
:
@"%0.f"
,
yValueParsed
];
return
labelText
;
return
[
barChartFormatter
stringFromNumber
:[
NSNumber
numberWithFloat
:
yValue
]];
};
self
.
barChart
.
yChartLabelWidth
=
20
.
0
;
self
.
barChart
.
chartMarginLeft
=
30
.
0
;
self
.
barChart
.
chartMarginRight
=
10
.
0
;
self
.
barChart
.
chartMarginTop
=
5
.
0
;
self
.
barChart
.
chartMarginBottom
=
10
.
0
;
self
.
barChart
.
labelMarginTop
=
5
.
0
;
self
.
barChart
.
showChartBorder
=
YES
;
[
self
.
barChart
setXLabels
:@[
@"2"
,
@"3"
,
@"4"
,
@"5"
,
@"2"
,
@"3"
,
@"4"
,
@"5"
]];
// self.barChart.yLabels = @[@-10,@0,@10];
// [self.barChart setYValues:@[@10000.0,@30000.0,@10000.0,@100000.0,@500000.0,@1000000.0,@1150000.0,@2150000.0]];
[
self
.
barChart
setYValues
:@[
@10.82
,
@1.88
,
@6.96
,
@33.93
,
@10.82
,
@1.88
,
@6.96
,
@33.93
]];
[
self
.
barChart
setStrokeColors
:@[
PNGreen
,
PNGreen
,
PNRed
,
PNGreen
,
PNGreen
,
PNGreen
,
PNRed
,
PNGreen
]];
self
.
barChart
.
isGradientShow
=
NO
;
...
...
Please
register
or
login
to post a comment