Ali Jatoi Ali Jatoi - 1 month ago 5
Objective-C Question

i am not able to load JBBarChartView into my view? I cannot see anything in the view

I have created a view in the header file. import the BarChartView in the header file as well.

@property (weak, nonatomic) IBOutlet JBBarChartView *barChartView;

- (void)viewDidLoad
{
JBBarChartView *barChartView = [[JBBarChartView alloc] init];
barChartView.dataSource = self;
barChartView.delegate = self;
[self addSubview:barChartView];
}


I added some built in methods which gives the property to JBBarChart

- (UIColor *)barSelectionColorForBarChartView:(JBBarChartView *)barChartView
{
return [UIColor greenColor]; // color of selection view
}
- (BOOL)slideNavigationControllerShouldDisplayLeftMenu
{
return YES;
}
- (UIColor *)barChartView:(JBBarChartView *)barChartView colorForBarViewAtIndex:(NSUInteger)index
{
return [UIColor greenColor];
}

- (NSUInteger)numberOfBarsInBarChartView:(JBBarChartView *)barChartView
{
return 4;
}
- (CGFloat)barChartView:(JBBarChartView *)barChartView heightForBarViewAtAtIndex:(NSUInteger)index
{
return 100.0;
}


Any Help would be highly appreciated, there is still nothing in the view

Answer

need to be update one line only

- (void)viewDidLoad
{
JBBarChartView *barChartView = [[JBBarChartView alloc] init];
barChartView.dataSource = self;
barChartView.delegate = self;
[self.view addSubview:barChartView];//Update this line
}