0

I am using ECGraph in my application, I need to add myTopNameStr dynamically in drawRect method which is defined in DisplayView.m (inherited from UIView) from an NSArray which is in ECGraphViewController.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]];

}
Ankur Arya
  • 4,693
  • 5
  • 29
  • 50

1 Answers1

0

I'm also looking how to integrate ecgraph in iOS app and to show graph in specific area over the application .. Well for your question, you can set your data to some central place first (like AppDelegate or some of shared instance class) and then you can access it in drawRect method.

Ans
  • 3,461
  • 3
  • 23
  • 24