Showing
1 changed file
with
64 additions
and
28 deletions
| @@ -37,46 +37,46 @@ You will need LLVM 3.0 or later in order to build PNChart. | @@ -37,46 +37,46 @@ You will need LLVM 3.0 or later in order to build PNChart. | ||
| 37 | [](https://dl.dropboxusercontent.com/u/1599662/line.png) | 37 | [](https://dl.dropboxusercontent.com/u/1599662/line.png) |
| 38 | 38 | ||
| 39 | ```objective-c | 39 | ```objective-c |
| 40 | - #import "PNChart.h" | 40 | +#import "PNChart.h" |
| 41 | 41 | ||
| 42 | - //For LineChart | 42 | +//For Line Chart |
| 43 | - PNLineChart * lineChart = [[PNLineChart alloc] initWithFrame:CGRectMake(0, 135.0, SCREEN_WIDTH, 200.0)]; | 43 | +PNLineChart * lineChart = [[PNLineChart alloc] initWithFrame:CGRectMake(0, 135.0, SCREEN_WIDTH, 200.0)]; |
| 44 | - [lineChart setXLabels:@[@"SEP 1",@"SEP 2",@"SEP 3",@"SEP 4",@"SEP 5"]]; | 44 | +[lineChart setXLabels:@[@"SEP 1",@"SEP 2",@"SEP 3",@"SEP 4",@"SEP 5"]]; |
| 45 | 45 | ||
| 46 | - // Line Chart No.1 | 46 | +// Line Chart No.1 |
| 47 | - NSArray * data01Array = @[@60.1, @160.1, @126.4, @262.2, @186.2]; | 47 | +NSArray * data01Array = @[@60.1, @160.1, @126.4, @262.2, @186.2]; |
| 48 | - PNLineChartData *data01 = [PNLineChartData new]; | 48 | +PNLineChartData *data01 = [PNLineChartData new]; |
| 49 | - data01.color = PNFreshGreen; | 49 | +data01.color = PNFreshGreen; |
| 50 | - data01.itemCount = lineChart.xLabels.count; | 50 | +data01.itemCount = lineChart.xLabels.count; |
| 51 | - data01.getData = ^(NSUInteger index) { | 51 | +data01.getData = ^(NSUInteger index) { |
| 52 | CGFloat yValue = [data01Array[index] floatValue]; | 52 | CGFloat yValue = [data01Array[index] floatValue]; |
| 53 | return [PNLineChartDataItem dataItemWithY:yValue]; | 53 | return [PNLineChartDataItem dataItemWithY:yValue]; |
| 54 | - }; | 54 | +}; |
| 55 | - // Line Chart No.2 | 55 | +// Line Chart No.2 |
| 56 | - NSArray * data02Array = @[@20.1, @180.1, @26.4, @202.2, @126.2]; | 56 | +NSArray * data02Array = @[@20.1, @180.1, @26.4, @202.2, @126.2]; |
| 57 | - PNLineChartData *data02 = [PNLineChartData new]; | 57 | +PNLineChartData *data02 = [PNLineChartData new]; |
| 58 | - data02.color = PNTwitterColor; | 58 | +data02.color = PNTwitterColor; |
| 59 | - data02.itemCount = lineChart.xLabels.count; | 59 | +data02.itemCount = lineChart.xLabels.count; |
| 60 | - data02.getData = ^(NSUInteger index) { | 60 | +data02.getData = ^(NSUInteger index) { |
| 61 | CGFloat yValue = [data02Array[index] floatValue]; | 61 | CGFloat yValue = [data02Array[index] floatValue]; |
| 62 | return [PNLineChartDataItem dataItemWithY:yValue]; | 62 | return [PNLineChartDataItem dataItemWithY:yValue]; |
| 63 | - }; | 63 | +}; |
| 64 | 64 | ||
| 65 | - lineChart.chartData = @[data01, data02]; | 65 | +lineChart.chartData = @[data01, data02]; |
| 66 | - [lineChart strokeChart]; | 66 | +[lineChart strokeChart]; |
| 67 | 67 | ||
| 68 | ``` | 68 | ``` |
| 69 | 69 | ||
| 70 | [](https://dl.dropboxusercontent.com/u/1599662/bar.png) | 70 | [](https://dl.dropboxusercontent.com/u/1599662/bar.png) |
| 71 | 71 | ||
| 72 | ```objective-c | 72 | ```objective-c |
| 73 | - #import "PNChart.h" | 73 | +#import "PNChart.h" |
| 74 | 74 | ||
| 75 | - //For BarChart | 75 | +//For BarC hart |
| 76 | - PNBarChart * barChart = [[PNBarChart alloc] initWithFrame:CGRectMake(0, 135.0, SCREEN_WIDTH, 200.0)]; | 76 | +PNBarChart * barChart = [[PNBarChart alloc] initWithFrame:CGRectMake(0, 135.0, SCREEN_WIDTH, 200.0)]; |
| 77 | - [barChart setXLabels:@[@"SEP 1",@"SEP 2",@"SEP 3",@"SEP 4",@"SEP 5"]]; | 77 | +[barChart setXLabels:@[@"SEP 1",@"SEP 2",@"SEP 3",@"SEP 4",@"SEP 5"]]; |
| 78 | - [barChart setYValues:@[@1, @10, @2, @6, @3]]; | 78 | +[barChart setYValues:@[@1, @10, @2, @6, @3]]; |
| 79 | - [barChart strokeChart]; | 79 | +[barChart strokeChart]; |
| 80 | 80 | ||
| 81 | ``` | 81 | ``` |
| 82 | 82 | ||
| @@ -86,7 +86,7 @@ You will need LLVM 3.0 or later in order to build PNChart. | @@ -86,7 +86,7 @@ You will need LLVM 3.0 or later in order to build PNChart. | ||
| 86 | ```objective-c | 86 | ```objective-c |
| 87 | #import "PNChart.h" | 87 | #import "PNChart.h" |
| 88 | 88 | ||
| 89 | -//For CircleChart | 89 | +//For Circle Chart |
| 90 | 90 | ||
| 91 | PNCircleChart * circleChart = [[PNCircleChart alloc] initWithFrame:CGRectMake(0, 80.0, SCREEN_WIDTH, 100.0) andTotal:[NSNumber numberWithInt:100] andCurrent:[NSNumber numberWithInt:60] andClockwise:NO]; | 91 | PNCircleChart * circleChart = [[PNCircleChart alloc] initWithFrame:CGRectMake(0, 80.0, SCREEN_WIDTH, 100.0) andTotal:[NSNumber numberWithInt:100] andCurrent:[NSNumber numberWithInt:60] andClockwise:NO]; |
| 92 | circleChart.backgroundColor = [UIColor clearColor]; | 92 | circleChart.backgroundColor = [UIColor clearColor]; |
| @@ -100,7 +100,7 @@ circleChart.backgroundColor = [UIColor clearColor]; | @@ -100,7 +100,7 @@ circleChart.backgroundColor = [UIColor clearColor]; | ||
| 100 | 100 | ||
| 101 | ```objective-c | 101 | ```objective-c |
| 102 | # import "PNChart.h" | 102 | # import "PNChart.h" |
| 103 | -//For PieChart | 103 | +//For Pie Chart |
| 104 | NSArray *items = @[[PNPieChartDataItem dataItemWithValue:10 color:PNRed], | 104 | NSArray *items = @[[PNPieChartDataItem dataItemWithValue:10 color:PNRed], |
| 105 | [PNPieChartDataItem dataItemWithValue:20 color:PNBlue description:@"WWDC"], | 105 | [PNPieChartDataItem dataItemWithValue:20 color:PNBlue description:@"WWDC"], |
| 106 | [PNPieChartDataItem dataItemWithValue:40 color:PNGreen description:@"GOOL I/O"], | 106 | [PNPieChartDataItem dataItemWithValue:40 color:PNGreen description:@"GOOL I/O"], |
| @@ -114,6 +114,42 @@ pieChart.descriptionTextFont = [UIFont fontWithName:@"Avenir-Medium" size:14.0] | @@ -114,6 +114,42 @@ pieChart.descriptionTextFont = [UIFont fontWithName:@"Avenir-Medium" size:14.0] | ||
| 114 | [pieChart strokeChart]; | 114 | [pieChart strokeChart]; |
| 115 | ``` | 115 | ``` |
| 116 | 116 | ||
| 117 | +[](https://dl.dropboxusercontent.com/u/1599662/scatter.png) | ||
| 118 | + | ||
| 119 | +```objective-c | ||
| 120 | +# import "PNChart.h" | ||
| 121 | +//For Scatter Chart | ||
| 122 | + | ||
| 123 | +PNScatterChart *scatterChart = [[PNScatterChart alloc] initWithFrame:CGRectMake(SCREEN_WIDTH /6.0 - 30, 135, 280, 200)]; | ||
| 124 | +[scatterChart setAxisXWithMinimumValue:20 andMaxValue:100 toTicks:6]; | ||
| 125 | +[scatterChart setAxisYWithMinimumValue:30 andMaxValue:50 toTicks:5]; | ||
| 126 | + | ||
| 127 | +NSArray * data01Array = [self randomSetOfObjects]; | ||
| 128 | +PNScatterChartData *data01 = [PNScatterChartData new]; | ||
| 129 | +data01.strokeColor = PNGreen; | ||
| 130 | +data01.fillColor = PNFreshGreen; | ||
| 131 | +data01.size = 2; | ||
| 132 | +data01.itemCount = [[data01Array objectAtIndex:0] count]; | ||
| 133 | +data01.inflexionPointStyle = PNScatterChartPointStyleCircle; | ||
| 134 | +__block NSMutableArray *XAr1 = [NSMutableArray arrayWithArray:[data01Array objectAtIndex:0]]; | ||
| 135 | +__block NSMutableArray *YAr1 = [NSMutableArray arrayWithArray:[data01Array objectAtIndex:1]]; | ||
| 136 | +data01.getData = ^(NSUInteger index) { | ||
| 137 | + CGFloat xValue = [[XAr1 objectAtIndex:index] floatValue]; | ||
| 138 | + CGFloat yValue = [[YAr1 objectAtIndex:index] floatValue]; | ||
| 139 | + return [PNScatterChartDataItem dataItemWithX:xValue AndWithY:yValue]; | ||
| 140 | +}; | ||
| 141 | + | ||
| 142 | +[scatterChart setup]; | ||
| 143 | +self.scatterChart.chartData = @[data01]; | ||
| 144 | +/*** | ||
| 145 | +this is for drawing line to compare | ||
| 146 | +CGPoint start = CGPointMake(20, 35); | ||
| 147 | +CGPoint end = CGPointMake(80, 45); | ||
| 148 | +[scatterChart drawLineFromPoint:start ToPoint:end WithLineWith:2 AndWithColor:PNBlack]; | ||
| 149 | +***/ | ||
| 150 | +scatterChart.delegate = self; | ||
| 151 | +``` | ||
| 152 | + | ||
| 117 | #### Update Value | 153 | #### Update Value |
| 118 | 154 | ||
| 119 | Now it's easy to update value in real time | 155 | Now it's easy to update value in real time |
-
Please register or login to post a comment