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

Designed initializer of BarChartDataSet crash #1180

Closed
FryFanti opened this issue Jun 27, 2016 · 0 comments
Closed

Designed initializer of BarChartDataSet crash #1180

FryFanti opened this issue Jun 27, 2016 · 0 comments

Comments

@FryFanti
Copy link

FryFanti commented Jun 27, 2016

When I try to use

- (nonnull instancetype)initWithYVals:(NSArray<ChartDataEntry *> * _Nullable)yVals label:(NSString * _Nullable)label OBJC_DESIGNATED_INITIALIZER;

the app crash with this stack trace

schermata 2016-06-27 alle 14 29 32

This is how I create Data Set

- (void)setChartValues:(NSArray <NSNumber *> *)values labels:(NSArray <NSString *> *)labels {

    NSMutableArray <ChartDataEntry *> *dataEntry = [NSMutableArray array];

    [values enumerateObjectsUsingBlock:^(NSNumber * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        [dataEntry addObject:[[ChartDataEntry alloc] initWithValue:[obj doubleValue] xIndex:idx]];
    }];

    BarChartDataSet *barChartDataSet = [[BarChartDataSet alloc] initWithYVals:dataEntry label:@"FF"];
    barChartDataSet.colors = @[[UIColor colorWithHexString:@"#8cebff"],
                               [UIColor colorWithHexString:@"#c5ff8c"],
                               [UIColor colorWithHexString:@"#ffd28c"]];

    BarChartData *barChartData = [[BarChartData alloc] initWithXVals:labels dataSet:barChartDataSet];

    self.barChart.data = barChartData;
}

UPDATE
I change ChartDataEntry into BarChartDataEntry and now works well.

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

1 participant