Iphone ECGraph的动态值
在我的应用程序中使用时,我需要在Iphone ECGraph的动态值,iphone,ios,graph,nsarray,drawrect,Iphone,Ios,Graph,Nsarray,Drawrect,在我的应用程序中使用时,我需要在drawRect方法中动态添加myTopNameStr,该方法在DisplayView.m中定义(继承自UIView),它来自ECGraphViewController.m中的NSArray - (void)drawRect:(CGRect)rect { NSLog(@"==========%@",topPlace); // Drawing code CGContextRef _context = UIGraphicsGetCurrentContext(); E
drawRect
方法中动态添加myTopNameStr
,该方法在DisplayView.m
中定义(继承自UIView
),它来自ECGraphViewController.m
中的NSArray
- (void)drawRect:(CGRect)rect {
NSLog(@"==========%@",topPlace);
// Drawing code
CGContextRef _context = UIGraphicsGetCurrentContext();
ECGraph *graph = [[ECGraph alloc] initWithFrame:CGRectMake(0,0, 320, 480)
withContext:_context isPortrait:YES];
ECGraphItem *item1 = [[ECGraphItem alloc] init];
item1.isPercentage = YES;
item1.yValue = 71;
item1.width = 55;
item1.myTopNameStr = [topPlace objectAtIndex:0];
// item1.name = @"item1";
ECGraphItem *item2 = [[ECGraphItem alloc] init];
item2.isPercentage = YES;
item2.yValue = 61;
item2.width = 55;
// item2.myTopNameStr =[_topNameAry objectAtIndex:1];
//item2.name = @"item2";
ECGraphItem *item3 = [[ECGraphItem alloc] init];
item3.isPercentage = NO;
item3.yValue = 51;
item3.width = 55;
// item3.myTopNameStr =[_topNameAry objectAtIndex:2];
// item3.name = @"item3";
NSArray *items = [[NSArray alloc] initWithObjects:item1,item2,item3,nil];
// [graph setXaxisTitle:@"name"];
// [graph setYaxisTitle:@"Percentage"];
// [graph setGraphicTitle:@"Top Chat.Points"];
[graph setDelegate:self];
[graph setBackgroundColor:[UIColor whiteColor]];
[graph drawHistogramWithItems:items lineWidth:0 color:[UIColor clearColor]];
}
我还研究了如何将ecgraph集成到iOS应用程序中,以及如何在应用程序的特定区域显示该图形。。对于您的问题,您可以先将数据设置到某个中心位置(如AppDelegate或某些共享实例类),然后在drawRect方法中访问它