I'm trying to implement a bar chart into my iOS app. I am using JBChartView. Everything is working fine, but there is no colour to the bars except when I press on them using the touchEvent.
Does anyone have any experience with this particular plugin to help me get it working correctly?
Thanks
- (void)viewDidLoad
{
_barChartView = [[JBBarChartView alloc] init];
_barChartView.delegate = self;
_barChartView.dataSource = self;
_tableView.backgroundColor =[UIColor clearColor];
_barChartView.frame = CGRectMake(0,0,200,200);
_barChartView.backgroundColor = [UIColor clearColor];
[_barChartView reloadData];
[_barChart addSubview: _barChartView];
}
- (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;
}
The problem appears to be with how
JBBarChartView
"normalizes" the values. Per the header file forJBBarChartView.h
:Because of this "normalization" when all of your values are the same (
100.0f
) it normalizes them all to 0, so there is no bar to display. Luckily, it is open-source, so you just need to open up the implementation file and make a little modification: