1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
| #import "ViewController.h"
#import "NChart3D/NChart3D.h"
@interface ViewController ()
@end
@implementation ViewController
{
NChartView *m_view;
}
- (void)dealloc
{
[m_view release];
[super dealloc];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
m_view = [[NChartView alloc] initWithFrame:CGRectZero];
m_view.chart.licenseKey = @"";
m_view.chart.cartesianSystem.margin = NChartMarginMake(10.0f, 10.0f, 10.0f, 20.0f);
m_view.chart.shouldAntialias = YES;
NChartColumnSeries *serires = [[NChartColumnSeries new] autorelease];
serires.brush = [NChartSolidColorBrush solidColorBrushWithColor:[UIColor colorWithRed:0.0 green:0.7 blue:0.4 alpha:1.0]];
serires.dataSource = self;
[m_view.chart addSeries:serires];
[m_view.chart updateData];
self.view = m_view; //使用新建的view
}
- (NSArray *)seriesDataSourcePointsForSeries:(NChartSeries *)series
{
NSMutableArray *result = [NSMutableArray array];
for(int i = 0; i < 10; i++)
[result addObject:[NChartPoint pointWithState:[NChartPointState pointStateAlignedToXWithX:i Y:(rand()%30) + 1]forSeries:series]];
return result;
}
- (NSString *)seriesDataSourceNameForSeries:(NChartSeries *)series
{
return @"My series";
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
|