0

我在我的应用程序中使用ECGraph,我需要myTopNameStr动态添加在(继承自)drawRect中定义的方法中DisplayView.mUIViewNSArrayECGraphViewController.m

 - (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]];

}
4

1 回答 1

0

我也在寻找如何在 iOS 应用程序中集成 ecgraph 并在应用程序的特定区域显示图形.. 对于您的问题,您可以先将数据设置到某个中心位置(如 AppDelegate 或一些共享实例类)和然后你可以在 drawRect 方法中访问它。

于 2013-04-15T09:33:28.297 回答