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
Kevin
2015-02-17 09:37:21 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
3f666b100d41f87acb55031496216bf0b38ce9ce
3f666b10
2 parents
59f92a7e
20dfd351
Merge pull request #159 from lunzii/master
Add setAxisXLabel/setAxisYLabel
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
2 deletions
PNChart/PNScatterChart.h
PNChart/PNScatterChart.m
PNChartDemo/PCChartViewController.m
PNChart/PNScatterChart.h
View file @
3f666b1
...
...
@@ -24,7 +24,8 @@
@property
(
nonatomic
)
UIColor
*
axisColor
;
@property
(
nonatomic
)
CGFloat
axisWidth
;
/** String formatter for float values in y-axis labels. If not set, defaults to @"%1.f" */
/** String formatter for float values in x-axis/y-axis labels. If not set, defaults to @"%1.f" */
@property
(
nonatomic
,
strong
)
NSString
*
xLabelFormat
;
@property
(
nonatomic
,
strong
)
NSString
*
yLabelFormat
;
/** Default is true. */
...
...
@@ -53,6 +54,8 @@
-
(
void
)
setAxisXWithMinimumValue
:(
CGFloat
)
minVal
andMaxValue
:(
CGFloat
)
maxVal
toTicks
:(
int
)
numberOfTicks
;
-
(
void
)
setAxisYWithMinimumValue
:(
CGFloat
)
minVal
andMaxValue
:(
CGFloat
)
maxVal
toTicks
:(
int
)
numberOfTicks
;
-
(
void
)
setAxisXLabel
:(
NSArray
*
)
array
;
-
(
void
)
setAxisYLabel
:(
NSArray
*
)
array
;
-
(
void
)
setup
;
-
(
void
)
drawLineFromPoint
:
(
CGPoint
)
startPoint
ToPoint
:
(
CGPoint
)
endPoint
WithLineWith
:
(
CGFloat
)
lineWidth
AndWithColor
:
(
UIColor
*
)
color
;
...
...
PNChart/PNScatterChart.m
View file @
3f666b1
...
...
@@ -123,7 +123,7 @@
_AxisX_partNumber
=
numberOfTicks
-
1
;
_AxisX_step
=
(
float
)((
maxVal
-
minVal
)
/
_AxisX_partNumber
);
NSString
*
LabelFormat
=
self
.
y
LabelFormat
?
:
@"%1.f"
;
NSString
*
LabelFormat
=
self
.
x
LabelFormat
?
:
@"%1.f"
;
CGFloat
tempValue
=
minVal
;
UILabel
*
label
=
[[
UILabel
alloc
]
init
];
label
.
text
=
[
NSString
stringWithFormat
:
LabelFormat
,
minVal
]
;
...
...
@@ -156,6 +156,28 @@
}
}
-
(
void
)
setAxisXLabel
:
(
NSArray
*
)
array
{
if
(
array
.
count
==
++
_AxisX_partNumber
){
[
_axisX_labels
removeAllObjects
];
for
(
int
i
=
0
;
i
<
array
.
count
;
i
++
){
UILabel
*
label
=
[[
UILabel
alloc
]
init
];
label
.
text
=
[
array
objectAtIndex
:
i
];
[
_axisX_labels
addObject
:
label
];
}
}
}
-
(
void
)
setAxisYLabel
:
(
NSArray
*
)
array
{
if
(
array
.
count
==
++
_AxisY_partNumber
){
[
_axisY_labels
removeAllObjects
];
for
(
int
i
=
0
;
i
<
array
.
count
;
i
++
){
UILabel
*
label
=
[[
UILabel
alloc
]
init
];
label
.
text
=
[
array
objectAtIndex
:
i
];
[
_axisY_labels
addObject
:
label
];
}
}
}
-
(
void
)
vectorXSetup
{
_AxisX_partNumber
+=
1
;
...
...
PNChartDemo/PCChartViewController.m
View file @
3f666b1
...
...
@@ -129,8 +129,11 @@
self
.
titleLabel
.
text
=
@"Scatter Chart"
;
self
.
scatterChart
=
[[
PNScatterChart
alloc
]
initWithFrame
:
CGRectMake
(
SCREEN_WIDTH
/
6
.
0
-
30
,
135
,
280
,
200
)];
// self.scatterChart.yLabelFormat = @"xxx %1.1f";
[
self
.
scatterChart
setAxisXWithMinimumValue
:
20
andMaxValue
:
100
toTicks
:
6
];
[
self
.
scatterChart
setAxisYWithMinimumValue
:
30
andMaxValue
:
50
toTicks
:
5
];
[
self
.
scatterChart
setAxisXLabel
:@[
@"x1"
,
@"x2"
,
@"x3"
,
@"x4"
,
@"x5"
,
@"x6"
]];
[
self
.
scatterChart
setAxisYLabel
:@[
@"y1"
,
@"y2"
,
@"y3"
,
@"y4"
,
@"y5"
]];
NSArray
*
data01Array
=
[
self
randomSetOfObjects
];
PNScatterChartData
*
data01
=
[
PNScatterChartData
new
];
...
...
@@ -141,6 +144,7 @@
data01
.
inflexionPointStyle
=
PNScatterChartPointStyleCircle
;
__block
NSMutableArray
*
XAr1
=
[
NSMutableArray
arrayWithArray
:[
data01Array
objectAtIndex
:
0
]];
__block
NSMutableArray
*
YAr1
=
[
NSMutableArray
arrayWithArray
:[
data01Array
objectAtIndex
:
1
]];
data01
.
getData
=
^
(
NSUInteger
index
)
{
CGFloat
xValue
=
[[
XAr1
objectAtIndex
:
index
]
floatValue
];
CGFloat
yValue
=
[[
YAr1
objectAtIndex
:
index
]
floatValue
];
...
...
Please
register
or
login
to post a comment