我正在使用 EASYGRAPH 在 iphone 应用程序中创建图形问题是它获取静态值并显示图形我希望值应该是来自该图形的视图控制器的动态值。
图形的 UIView
#import <UIKit/UIKit.h>
#import "ECGraph.h"
#import "ECGraphItem.h"
@class GraphsViewController;
@interface Display : UIView {
NSArray *percentages;
}
@property(nonatomic,retain)NSArray*percentages;
-(void) setPercentageArray:(NSArray*) array;
@end
#import "Display.h"
#import "ECGraph.h"
@implementation Display
@synthesize percentages;
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
// Initialization code.
}
return self;
}
- (void)drawRect:(CGRect)rect {
CGContextRef _context = UIGraphicsGetCurrentContext();
ECGraph *graph = [[ECGraph alloc] initWithFrame:CGRectMake(300,500,320,200) withContext:_context isPortrait:NO];
//300,500,320, 200
ECGraphItem *item1 = [[ECGraphItem alloc] init];
ECGraphItem *item2 = [[ECGraphItem alloc] init];
item1.isPercentage = YES;
item1.yValue=80;
item1.width = 35;
item1.name = @"item1";
item2.isPercentage = YES;
item2.yValue =17;
item2.width = 35;
item2.name = @"item2";
NSArray *items = [[NSArray alloc] initWithObjects:item1,item2,nil];
[graph setXaxisTitle:@"name"];
[graph setYaxisTitle:@"Percentage"];
[graph setGraphicTitle:@"Histogram"];
[graph setDelegate:self];
[graph setBackgroundColor:[UIColor colorWithRed:220/255.0 green:220/255.0 blue:220/255.0 alpha:1]];
[graph drawHistogramWithItems:items lineWidth:2 color:[UIColor blackColor]];
}