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:53:34 +0100
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
865bd3b5a3c331cbd6120aac76fa5d8cbb38a66b
865bd3b5
2 parents
a2dc6a6d
22e9eb78
merge
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
81 additions
and
3 deletions
PNChart/PNCircleChart.m
PNChart/PNLineChart.m
PNChart/PNPieChart.m
PNChart/PNPieChartDataItem.m
PNChart/PNScatterChart.m
README.md
PNChart/PNCircleChart.m
View file @
865bd3b
...
...
@@ -157,7 +157,7 @@ displayCountingLabel:(BOOL)displayCountingLabel
[
_circle
addAnimation
:
pathAnimation
forKey
:
@"strokeEndAnimation"
];
_circle
.
strokeEnd
=
[
_current
floatValue
]
/
[
_total
floatValue
];
[
_countingLabel
countFrom
:
0
to
:[
_current
floatValue
]
withDuration
:
self
.
duration
];
[
_countingLabel
countFrom
:
0
to
:[
_current
floatValue
]
/
([
_total
floatValue
]
/
100
.
0
)
withDuration
:
self
.
duration
];
// Check if user wants to add a gradient from the start color to the bar color
...
...
@@ -235,4 +235,4 @@ displayCountingLabel:(BOOL)displayCountingLabel
_total
=
total
;
}
@end
\ No newline at end of file
@end
...
...
PNChart/PNLineChart.m
View file @
865bd3b
...
...
@@ -104,6 +104,20 @@
}
}
-
(
CGFloat
)
computeEqualWidthForXLabels
:(
NSArray
*
)
xLabels
{
CGFloat
xLabelWidth
;
if
(
_showLabel
)
{
xLabelWidth
=
_chartCavanWidth
/
[
xLabels
count
];
}
else
{
xLabelWidth
=
(
self
.
frame
.
size
.
width
)
/
[
xLabels
count
];
}
return
xLabelWidth
;
}
-
(
void
)
setXLabels
:(
NSArray
*
)
xLabels
{
CGFloat
xLabelWidth
;
...
...
PNChart/PNPieChart.m
View file @
865bd3b
This diff is collapsed. Click to expand it.
PNChart/PNPieChartDataItem.m
View file @
865bd3b
...
...
@@ -27,4 +27,11 @@
return
item
;
}
-
(
void
)
setValue
:(
CGFloat
)
value
{
NSAssert
(
value
>=
0
,
@"value should >= 0"
);
if
(
value
!=
_value
){
_value
=
value
;
}
}
@end
...
...
PNChart/PNScatterChart.m
View file @
865bd3b
...
...
@@ -156,6 +156,24 @@
}
}
-
(
NSArray
*
)
getAxisMinMax
:
(
NSArray
*
)
xValues
{
float
min
=
[
xValues
[
0
]
floatValue
];
float
max
=
[
xValues
[
0
]
floatValue
];
for
(
NSNumber
*
number
in
xValues
)
{
if
([
number
floatValue
]
>
max
)
max
=
[
number
floatValue
];
if
([
number
floatValue
]
<
min
)
min
=
[
number
floatValue
];
}
NSArray
*
result
=
@[[
NSNumber
numberWithFloat
:
min
],
[
NSNumber
numberWithFloat
:
max
]];
return
result
;
}
-
(
void
)
setAxisXLabel
:
(
NSArray
*
)
array
{
if
(
array
.
count
==
++
_AxisX_partNumber
){
[
_axisX_labels
removeAllObjects
];
...
...
README.md
View file @
865bd3b
...
...
@@ -64,7 +64,6 @@ data02.getData = ^(NSUInteger index) {
lineChart.chartData = @[data01, data02];
[lineChart strokeChart];
```
[

](https://dl.dropboxusercontent.com/u/1599662/bar.png)
...
...
@@ -150,6 +149,46 @@ CGPoint end = CGPointMake(80, 45);
scatterChart.delegate = self;
```
#### Legend
Legend has been added to PNChart for Line and Pie Charts. Legend items position can be stacked or in series.
[](https://dl.dropboxusercontent.com/u/4904447/pnchart_legend_1.png)
[](https://dl.dropboxusercontent.com/u/4904447/pnchart_legend_2.png)
```
objective-c
#import "PNChart.h"
//For Line Chart
//Add Line Titles for the Legend
data01.dataTitle = @"Alpha";
data02.dataTitle = @"Beta Beta Beta Beta";
//Build the legend
self.lineChart.legendStyle = PNLegendItemStyleSerial;
self.lineChart.legendFontSize = 12.0;
UIView
*
legend =
[
self.lineChart getLegendWithMaxWidth:320
]
;
//Move legend to the desired position and add to view
[
legend setFrame:CGRectMake(100, 400, legend.frame.size.width, legend.frame.size.height)
]
;
[
self.view addSubview:legend
]
;
//For Pie Chart
//Build the legend
self.pieChart.legendStyle = PNLegendItemStyleStacked;
self.pieChart.legendFontSize = 12.0;
UIView
*
legend =
[
self.pieChart getLegendWithMaxWidth:200
]
;
//Move legend to the desired position and add to view
[
legend setFrame:CGRectMake(130, 350, legend.frame.size.width, legend.frame.size.height)
]
;
[
self.view addSubview:legend
]
;
```
#### Update Value
Now it's easy to update value in real time
...
...
Please
register
or
login
to post a comment