Merge pull request #170 from sanandrea/master
Update readme with example for legend
Showing
1 changed file
with
40 additions
and
1 deletions
| @@ -64,7 +64,6 @@ data02.getData = ^(NSUInteger index) { | @@ -64,7 +64,6 @@ data02.getData = ^(NSUInteger index) { | ||
| 64 | 64 | ||
| 65 | lineChart.chartData = @[data01, data02]; | 65 | lineChart.chartData = @[data01, data02]; |
| 66 | [lineChart strokeChart]; | 66 | [lineChart strokeChart]; |
| 67 | - | ||
| 68 | ``` | 67 | ``` |
| 69 | 68 | ||
| 70 | [](https://dl.dropboxusercontent.com/u/1599662/bar.png) | 69 | [](https://dl.dropboxusercontent.com/u/1599662/bar.png) |
| @@ -150,6 +149,46 @@ CGPoint end = CGPointMake(80, 45); | @@ -150,6 +149,46 @@ CGPoint end = CGPointMake(80, 45); | ||
| 150 | scatterChart.delegate = self; | 149 | scatterChart.delegate = self; |
| 151 | ``` | 150 | ``` |
| 152 | 151 | ||
| 152 | +#### Legend | ||
| 153 | + | ||
| 154 | +Legend has been added to PNChart for Line and Pie Charts. Legend items position can be stacked or in series. | ||
| 155 | + | ||
| 156 | +[](https://dl.dropboxusercontent.com/u/4904447/pnchart_legend_1.png) | ||
| 157 | + | ||
| 158 | +[](https://dl.dropboxusercontent.com/u/4904447/pnchart_legend_2.png) | ||
| 159 | + | ||
| 160 | +```objective-c | ||
| 161 | +#import "PNChart.h" | ||
| 162 | + | ||
| 163 | +//For Line Chart | ||
| 164 | + | ||
| 165 | +//Add Line Titles for the Legend | ||
| 166 | +data01.dataTitle = @"Alpha"; | ||
| 167 | +data02.dataTitle = @"Beta Beta Beta Beta"; | ||
| 168 | + | ||
| 169 | +//Build the legend | ||
| 170 | +self.lineChart.legendStyle = PNLegendItemStyleSerial; | ||
| 171 | +self.lineChart.legendFontSize = 12.0; | ||
| 172 | +UIView *legend = [self.lineChart getLegendWithMaxWidth:320]; | ||
| 173 | + | ||
| 174 | +//Move legend to the desired position and add to view | ||
| 175 | +[legend setFrame:CGRectMake(100, 400, legend.frame.size.width, legend.frame.size.height)]; | ||
| 176 | +[self.view addSubview:legend]; | ||
| 177 | + | ||
| 178 | + | ||
| 179 | +//For Pie Chart | ||
| 180 | + | ||
| 181 | +//Build the legend | ||
| 182 | +self.pieChart.legendStyle = PNLegendItemStyleStacked; | ||
| 183 | +self.pieChart.legendFontSize = 12.0; | ||
| 184 | +UIView *legend = [self.pieChart getLegendWithMaxWidth:200]; | ||
| 185 | + | ||
| 186 | +//Move legend to the desired position and add to view | ||
| 187 | +[legend setFrame:CGRectMake(130, 350, legend.frame.size.width, legend.frame.size.height)]; | ||
| 188 | +[self.view addSubview:legend]; | ||
| 189 | +``` | ||
| 190 | + | ||
| 191 | + | ||
| 153 | #### Update Value | 192 | #### Update Value |
| 154 | 193 | ||
| 155 | Now it's easy to update value in real time | 194 | Now it's easy to update value in real time |
-
Please register or login to post a comment