简单的图形视图。
NGGraphView
目录复制到您的项目中。#import "NGGraphView.h"
#import "NGDataPoint.h"
...
NGGraphView *_graphView; // add this to your view controller.
// you will want to set up an IBOutlet like so...
@property (nonatomic, retain) IBOutlet NGGraphView *graphView;
// next you will go to your view in interface builder
// add a new UIView, set the type to NGGraphView, and connect it
// to this variable.
// finally you will want to initialize your graph view
// set it's properties to customize it's appearance
// and add some data to it...
[_graphView setTitle:@"My Test Graph"];
[_graphView setSubTitle:@"This is a test."];
[_graphView setLineColor:[UIColor blueColor]];
[_graphView setLineWidth:1.0];
[_graphView setSegments:5]; // this graph is divided up into five sections.
[_graphView setShowPoints:YES];
[_graphView setPointSize:7];
[_graphView setPointColor:[UIColor redColor]];
// now add some data, the NGDataPoint is used to add data to the graph view.
[_graphView addDataPoint:[NGDataPoint withLabel:@"first" andCount:3]];
[_graphView addDataPoint:[NGDataPoint withLabel:@"second" andCount:10]];
[_graphView addDataPoint:[NGDataPoint withLabel:@"third" andCount:7]];
[_graphView addDataPoint:[NGDataPoint withLabel:@"fourth" andCount:15]];
[_graphView addDataPoint:[NGDataPoint withLabel:@"fifth" andCount:19]];
您可以自定义以下属性。
[_graphView setTitle:@"My Test Graph"];
[_graphView setSubTitle:@"This is a test."];
[_graphView setLineColor:[UIColor blueColor]];
[_graphView setLineWidth:1.0];
[_graphView setSegments:5];
[_graphView setShowPoints:YES];
[_graphView setPointSize:7];
[_graphView setPointColor:[UIColor redColor]];
Nate Glenn, [email protected]
MIT