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

fix #1691 drawTransparentCircleHole bug #1711

Closed
wants to merge 1 commit into from

Conversation

liuxuan30
Copy link
Member

@liuxuan30 liuxuan30 commented Oct 25, 2016

fix #1691

  1. M_PI_2 is Pi / 2, not Pi * 2

    public var M_PI_2: Double { get } /* pi/2 */

  2. clockwise in UIKit and CoreGraphics is flipped(compared to UIBezierPath), though 0 to M_PI * 2 does not get affected by clockwise.

    The clockwise parameter determines the direction in which the arc is created; the actual direction of the final path is dependent on the current transformation matrix of the graphics context. For example, on iOS, a UIView flips the Y-coordinate by scaling the Y values by -1. In a flipped coordinate system, specifying a clockwise arc results in a counterclockwise arc after the transformation is applied.

  3. using even odd rule to fill between two arcs, not default.

BTW, I hate the new Apple API doc:(
The mentioned APIs above do not have any words, while the old doc has rich information. Have to use CGContextAddArc etc. to get the discussion

@liuxuan30
Copy link
Member Author

liuxuan30 commented Oct 25, 2016

test code (replace setDataCount in LineChart1ViewController):

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

    for (int i = 0; i < count; i++)
    {
        double val = arc4random_uniform(range) + 3;
        [values addObject:[[ChartDataEntry alloc] initWithX:i y:val]];
    }

    LineChartDataSet *set1 = nil;
    if (_chartView.data.dataSetCount > 0)
    {
        set1 = (LineChartDataSet *)_chartView.data.dataSets[0];
        set1.values = values;
        [_chartView.data notifyDataChanged];
        [_chartView notifyDataSetChanged];
    }
    else
    {
        set1 = [[LineChartDataSet alloc] initWithValues:values label:@"DataSet 1"];

        [set1 setHighlightColor:[UIColor clearColor]];
        set1.drawValuesEnabled = NO;
        set1.drawCirclesEnabled = YES;
        set1.circleHoleColor = [UIColor clearColor];
        set1.circleColors = [NSArray arrayWithObject:[UIColor orangeColor]];
        set1.circleHoleRadius = 7.0f;
        set1.circleRadius = 8.0f;
        set1.colors = [NSArray arrayWithObject:[UIColor blueColor]];

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

        LineChartData *data = [[LineChartData alloc] initWithDataSets:dataSets];

        _chartView.data = data;
    }
}

1. M_PI_2 is Pi / 2, not Pi * 2;
2. clockwise in UIKit and CoreGraphics is flipped;
3. using even odd rule to fill between two arcs
@codecov-io
Copy link

Current coverage is 18.68% (diff: 0.00%)

Merging #1711 into master will not change coverage

@@             master      #1711   diff @@
==========================================
  Files           123        123          
  Lines         14052      14052          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
  Hits           2626       2626          
  Misses        11426      11426          
  Partials          0          0          

Powered by Codecov. Last update 8ef870a...6798bc8

@codecov-io
Copy link

codecov-io commented Oct 25, 2016

Current coverage is 18.68% (diff: 0.00%)

Merging #1711 into master will not change coverage

@@             master      #1711   diff @@
==========================================
  Files           123        123          
  Lines         14052      14052          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
  Hits           2626       2626          
  Misses        11426      11426          
  Partials          0          0          

Powered by Codecov. Last update 8ef870a...33f63ac

@liuxuan30
Copy link
Member Author

@petester42 did you changed any config? Last week it still failed, but I restarted it today and it passes!

@pmairoldi
Copy link
Collaborator

I havent fixed it yet but I know why it fails. For pull requests the github token doesn't get used in the build. Because of this we hit the limit sometimes.

@liuxuan30
Copy link
Member Author

but it somehow passed.. randomly

@danielgindi
Copy link
Collaborator

This does not fix the hole thing for me...

@liuxuan30
Copy link
Member Author

liuxuan30 commented Nov 2, 2016

Oh no. Which part of the hole?
It' fine on my side:
fine
if revert back:
bad

@liuxuan30 liuxuan30 deleted the fixDrawCircles branch November 18, 2016 07:43
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

Successfully merging this pull request may close these issues.

Setting circleHoleColor to clear causes artifact
4 participants