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

Error while drawing radar chart #132

Closed
kajensen opened this issue Jun 7, 2015 · 4 comments
Closed

Error while drawing radar chart #132

kajensen opened this issue Jun 7, 2015 · 4 comments

Comments

@kajensen
Copy link

kajensen commented Jun 7, 2015

Let me preface this by saying this is the first time I've imported a swift project into an objective c (or really using swift, i'm not 100% sure whats happening when I look at swift code). I tried to setup just a test radar chart through IB, just like the demo. I actually use the exact demo code to generate the data. It crashes here after setting the data:
screen

@danielgindi
Copy link
Collaborator

This is not a crash- it's a breakpoint.

@kajensen
Copy link
Author

kajensen commented Jun 7, 2015

Yeah I know what a breakpoint is :) haha. I put those there to figure out what was going on. But I just deleted everything and re-installed it and it works...haha! Great lib, can't wait to check it out! Is there any way to get the source to compile quicker? It lags on "compiling swift files" for a long time and this is my first and only swift lib

@danielgindi
Copy link
Collaborator

That's in Apple's hands, improving with each Xcode release

@kajensen
Copy link
Author

kajensen commented Jun 8, 2015

hi again. Sorry to bother you, but I can't seem to implement a Bubble chart, I get "fatal error: NSArray element failed to match the Swift Array Element type". I have checked the types right before the crash occurs and they seem to be the correct type? And the call is casting with a "?" so it should nil them instead of raising an error. I am quite perplexed, hopefully you can help if you have time.
screen:
screen
code:

 NSMutableArray *xVals = [@[@"S",@"M",@"T",@"W",@"T",@"F",@"S"] mutableCopy];

NSMutableArray *yValsTemp = [[NSMutableArray alloc] init];
for (NSInteger i = 0; i < ActivityTypeCount; i++) {
    NSMutableArray *yValTemp = [[NSMutableArray alloc] init];
    for (NSString *day in xVals) {
        [yValTemp addObject:@[@(0),@(0)]];
    }
    [yValsTemp addObject:yValTemp];
}

for (PFSavedGo *pfSavedGo in _pfGos) {
    NSInteger dayOfWeek = [Convert dayOfTheWeek:pfSavedGo.createdAt]-1;//1-7, huh?
    ActivityType activityType = pfSavedGo.usedActivity.activityType;
    if (activityType < [yValsTemp count]) {
        NSMutableArray *yVal = [yValsTemp objectAtIndex:activityType];
        if (dayOfWeek < [yVal count]) {
            NSArray *actDay = [yVal objectAtIndex:dayOfWeek];
            NSNumber *val = actDay[0];
            NSNumber *size = actDay[1];
            [yVal replaceObjectAtIndex:dayOfWeek withObject:@[@(val.doubleValue + [Convert milesOrKilometersFromMeters:pfSavedGo.distanceInMeters]),@(size.integerValue + pfSavedGo.timeInSeconds)]];
        }
        //NSLog(@"%@",yVal);
    }
}

NSMutableArray *yValsActual = [[NSMutableArray alloc] init];
for (NSInteger i = 0; i < ActivityTypeCount; i++) {
    NSMutableArray *yValTemp = [yValsTemp objectAtIndex:i];
    NSMutableArray *yValActual = [[NSMutableArray alloc] init];
    for (NSArray *day in yValTemp) {
        NSNumber *val = day[0];
        NSNumber *size = day[1];
        [yValActual addObject:[[BubbleChartDataEntry alloc] initWithXIndex:i value:val.intValue size:size.doubleValue]];
    }
    [yValsActual addObject:yValActual];
}

NSMutableArray *dataSets = [[NSMutableArray alloc] init];
for (NSInteger i = 0; i < ActivityTypeCount; i++) {
    NSMutableArray *yValActual = [yValsActual objectAtIndex:i];
    BubbleChartDataSet *set = [[BubbleChartDataSet alloc] initWithYVals:yValActual label:[PFActivity majorActivityTypeStringForType:i]];
    [set setColor:ChartColorTemplates.colorful[i] alpha:0.50f];
    [set setDrawValuesEnabled:YES];
    [dataSets addObject:set];
}

BubbleChartData *data = [[BubbleChartData alloc] initWithXVals:xVals dataSets:dataSets];
[data setValueFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:7.f]];
[data setHighlightCircleWidth: 1.5];
[data setValueTextColor:UIColor.whiteColor];

_chartView.data = data;

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