Skip to content
This repository has been archived by the owner on Dec 2, 2020. It is now read-only.

Strange drawing result #259

Open
duzenko opened this issue Apr 11, 2016 · 2 comments
Open

Strange drawing result #259

duzenko opened this issue Apr 11, 2016 · 2 comments
Labels

Comments

@duzenko
Copy link

duzenko commented Apr 11, 2016

Hi, I'm new to this library. I'm trying to get a partial graph. The result is almost right - except for the white triangle where the the partial line ends. My code is very basic: total 8 points, two of them have data and others are left out

- (NSInteger)numberOfPointsInLineGraph:(BEMSimpleLineGraphView *)graph {
    NSIndexPath *indexPath = graphLinks[graph];
    NSDictionary *indicator = [self findIndicator:indexPath];
    NSArray *values = indicator[@"graphData"][@"labels"];
    return values.count;
}

- (CGFloat)lineGraph:(BEMSimpleLineGraphView *)graph valueForPointAtIndex:(NSInteger)index {
    NSIndexPath *indexPath = graphLinks[graph];
    NSDictionary *indicator = [self findIndicator:indexPath];
    NSArray *values = indicator[@"graphData"][@"values"];
    if (values.count > index) {
        return [values[index] floatValue];
    } else
        return BEMNullGraphValue;
}

simulator screen shot apr 11 2016 7 36 10 pm

@duzenko
Copy link
Author

duzenko commented Apr 12, 2016

The culprit seems to be the bottomPointsArray method. My workaround below:

- (NSArray *)bottomPointsArray {
    CGPoint bottomPointZero = CGPointMake(0, self.frame.size.height);
    CGPoint bottomPointFull = CGPointMake(self.frame.size.width, self.frame.size.height);
    NSMutableArray *bottomPoints = [NSMutableArray arrayWithArray:self.points];
    [bottomPoints insertObject:[NSValue valueWithCGPoint:bottomPointZero] atIndex:0];

// add one point to complete the polygon
    CGPoint oneMore = CGPointMake(self.frame.size.width, 0);
    [bottomPoints addObject:[NSValue valueWithCGPoint:oneMore]];

    [bottomPoints addObject:[NSValue valueWithCGPoint:bottomPointFull]];
    return bottomPoints;
}

@Boris-Em Boris-Em added the bug label May 2, 2016
@duzenko
Copy link
Author

duzenko commented Jun 12, 2016

I needed to change the visuals so now my code looks like this

- (NSArray *)bottomPointsArray {
    CGPoint bottomPointZero = CGPointMake(0, self.frame.size.height);
//    CGPoint bottomPointFull = CGPointMake(self.frame.size.width, self.frame.size.height);
    CGPoint bottomPointFull = [self.points.lastObject CGPointValue];
    bottomPointFull.y = self.frame.size.height;
    NSMutableArray *bottomPoints = [NSMutableArray arrayWithArray:self.points];
    [bottomPoints insertObject:[NSValue valueWithCGPoint:bottomPointZero] atIndex:0];
    [bottomPoints addObject:[NSValue valueWithCGPoint:bottomPointFull]];
    return bottomPoints;
}

simulator screen shot jun 12 2016 2 13 07 pm

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

No branches or pull requests

2 participants