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

Horizontal bar chart crashing after tap when more than one data set #1221

Closed
dvd110 opened this issue Jul 4, 2016 · 2 comments
Closed

Horizontal bar chart crashing after tap when more than one data set #1221

dvd110 opened this issue Jul 4, 2016 · 2 comments

Comments

@dvd110
Copy link

dvd110 commented Jul 4, 2016

I have tested this on the demo project. To reproduce modify HorizontalBarChartViewController.m with two data sets:

-(void)setDataCount:(int)count range:(double)range
{
NSMutableArray *xVals = [[NSMutableArray alloc] init];

for (int i = 0; i < count; i++)
{
    [xVals addObject:months[i % 12]];
}

NSMutableArray *yVals1 = [[NSMutableArray alloc] init];

for (int i = 0; i < count; i++)
{
    double mult = (range + 1);
    double val = (double) (arc4random_uniform(mult));
    [yVals1 addObject:[[BarChartDataEntry alloc] initWithValue:val xIndex:i]];
}

NSMutableArray *yVals2 = [[NSMutableArray alloc] init];

for (int i = 0; i < count; i++)
{
    double mult = (range + 1);
    double val = (double) (arc4random_uniform(mult));
    [yVals2 addObject:[[BarChartDataEntry alloc] initWithValue:val xIndex:i]];
}

BarChartDataSet *set1 = nil;
BarChartDataSet *set2 = nil;

if (_chartView.data.dataSetCount > 0)
{
    set1 = (BarChartDataSet *)_chartView.data.dataSets[0];
    set1.yVals = yVals1;
    _chartView.data.xValsObjc = xVals;
    [_chartView notifyDataSetChanged];
}
else
{
    set1 = [[BarChartDataSet alloc] initWithYVals:yVals1 label:@"DataSet"];
    set1.barSpace = 0.35;

    set2 = [[BarChartDataSet alloc] initWithYVals:yVals2 label:@"DataSet2"];
    set2.barSpace = 0.35;

    NSMutableArray *dataSets = [[NSMutableArray alloc] init];
    [dataSets addObject:set1];
    [dataSets addObject:set2];

    BarChartData *data = [[BarChartData alloc] initWithXVals:xVals dataSets:dataSets];
    [data setValueFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:10.f]];

    _chartView.data = data;
}

}

Suggestion:
HorizontalBarChartHighlighter.swift, line 79. I think it should be 'super.getXIndex(x)' instead of 'getXIndex(x)'.

@liuxuan30
Copy link
Member

Two things:

  1. what's the crash trace?
  2. towards your suggestion, is this related to crash or not? BUGFIX: fix infinite recursive call of getXIndex(_:) #1213 is pending for your suggestion

@dvd110
Copy link
Author

dvd110 commented Jul 5, 2016

Yes it's related to crash. #1213 is the same issue. Thanks.

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

2 participants