I am using EASYGRAPH for to create graph in iphone app problem is that it gets static values and shows graph i want that values should be dynamic come from view controller for this graph.
UIView For Graph
#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]];
}
First make a class that contains two properties width and height. then add it to array using addObject. now each object has individual values of height and width.
then use this
and then pass it to graph