kevinzhow

Add delegate readme

Showing 1 changed file with 39 additions and 1 deletions
@@ -31,7 +31,6 @@ You will need LLVM 3.0 or later in order to build PNChart. @@ -31,7 +31,6 @@ You will need LLVM 3.0 or later in order to build PNChart.
31 31
32 ### Copy the PNChart folder to your project 32 ### Copy the PNChart folder to your project
33 33
34 -#### Line Chart  
35 34
36 [![](https://dl.dropboxusercontent.com/u/1599662/line.png)](https://dl.dropboxusercontent.com/u/1599662/line.png) 35 [![](https://dl.dropboxusercontent.com/u/1599662/line.png)](https://dl.dropboxusercontent.com/u/1599662/line.png)
37 36
@@ -76,6 +75,45 @@ You will need LLVM 3.0 or later in order to build PNChart. @@ -76,6 +75,45 @@ You will need LLVM 3.0 or later in order to build PNChart.
76 75
77 ``` 76 ```
78 77
  78 +#### Callback
  79 +
  80 +```objective-c
  81 + #import "PNChart.h"
  82 +
  83 +//For LineChart
  84 +
  85 +PNChart * lineChart = [[PNChart alloc] initWithFrame:CGRectMake(0, 135.0, SCREEN_WIDTH, 200.0)];
  86 +lineChart.backgroundColor = [UIColor clearColor];
  87 +[lineChart setXLabels:@[@"SEP 1",@"SEP 2",@"SEP 3",@"SEP 4",@"SEP 5",@"SEP 6",@"SEP 7"]];
  88 +[lineChart setYValues:@[@1,@24,@12,@18,@30,@10,@21]];
  89 +[lineChart strokeChart];
  90 +
  91 +lineChart.delegate = self;
  92 +
  93 +[viewController.view addSubview:lineChartLabel];
  94 +[viewController.view addSubview:lineChart];
  95 +
  96 +viewController.title = @"Line Chart";
  97 +
  98 +```
  99 +
  100 +```objective-c
  101 + #import "PNChart.h"
  102 +
  103 + //For DelegateMethod
  104 +
  105 +
  106 +-(void)userClickedOnLineKeyPoint:(CGPoint)point andPointIndex:(NSInteger)index{
  107 + NSLog(@"Click Key on line %f, %f and index is %d",point.x, point.y,index);
  108 +}
  109 +
  110 +-(void)userClickedOnLinePoint:(CGPoint)point {
  111 + NSLog(@"Click on line %f, %f",point.x, point.y);
  112 +}
  113 +
  114 +```
  115 +
  116 +
79 ## License 117 ## License
80 118
81 This code is distributed under the terms and conditions of the [MIT license](LICENSE). 119 This code is distributed under the terms and conditions of the [MIT license](LICENSE).