Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with Bar Height #28

Closed
meduza opened this issue Apr 7, 2014 · 3 comments
Closed

Problem with Bar Height #28

meduza opened this issue Apr 7, 2014 · 3 comments

Comments

@meduza
Copy link

meduza commented Apr 7, 2014

I followed the tutorial and had a problem with bar height. Every time one bar has zero height (not showing in a view).

This is my code:

  • (void)viewDidLoad
    {
    [super viewDidLoad];
    // data array
    _data = @[@20, @30, @50];

    JBBarChartView *barChartView = [[JBBarChartView alloc] init];
    barChartView.delegate = self;
    barChartView.dataSource = self;
    barChartView.frame = CGRectMake(20, 120, 280, 200);
    barChartView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    barChartView.layer.borderWidth = 1;
    [self.view addSubview:barChartView];

    [barChartView reloadData];
    }

  • (NSUInteger)numberOfBarsInBarChartView:(JBBarChartView *)barChartView{
    NSLog(@"numberOfBarsInBarChartView: %lu", (unsigned long)[self.data count]);
    return [self.data count];
    }

  • (CGFloat)barChartView:(JBBarChartView *)barChartView heightForBarViewAtAtIndex:(NSUInteger)index{
    NSLog(@"heightForBarViewAtAtIndex: %lu, height: %f", index, [[self.data objectAtIndex:index] floatValue]);
    return [[self.data objectAtIndex:index] floatValue];
    }

Debug log:

12:51:55.054 App[5116:60b] numberOfBarsInBarChartView: 3
12:51:55.055 App[5116:60b] heightForBarViewAtAtIndex: 0, height: 20.000000
12:51:55.056 App[5116:60b] heightForBarViewAtAtIndex: 1, height: 30.000000
12:51:55.057 App[5116:60b] heightForBarViewAtAtIndex: 2, height: 50.000000

bar-image

@terryworona
Copy link
Collaborator

Try setting the barChartView.minimumValue = 0.0f;

By default, the minimum value of a chart is set to the minimum value of the datasource's collection.

@meduza
Copy link
Author

meduza commented Apr 8, 2014

Got it! Thank you!

@AnilkumarRabhasa
Copy link

Can you please give suggestions to this issue.

#236

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants