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

Max Y value sometimes get clipped #405

Closed
yas375 opened this issue Sep 22, 2015 · 6 comments
Closed

Max Y value sometimes get clipped #405

yas375 opened this issue Sep 22, 2015 · 6 comments

Comments

@yas375
Copy link
Contributor

yas375 commented Sep 22, 2015

I've just updated to the latest version of the library (v2.1.4, 7b85077) and have noticed an issue that sometimes max value doesn't show on the graph even it was shown before the update. Here is What I get now:

img_0018

Here is my setup:

  self.chartView.drawGridBackgroundEnabled = NO;
  self.chartView.doubleTapToZoomEnabled = NO;
  self.chartView.pinchZoomEnabled = YES;
  self.chartView.scaleYEnabled = NO;

  self.chartView.xAxis.drawGridLinesEnabled = NO;
  self.chartView.xAxis.avoidFirstLastClippingEnabled = YES;
  self.chartView.rightAxis.enabled = NO;

  self.chartView.marker = [FilledCircleChartMarker new];
  self.chartView.visibleXRangeMaximum = 99;

  self.chartView.leftAxis.startAtZeroEnabled = NO;
  self.chartView.leftAxis.customAxisMin = 1;
  self.chartView.leftAxis.customAxisMax = 10;

Here are the values I have:

ChartDataEntry, xIndex: 0, value 2.0
ChartDataEntry, xIndex: 1, value 1.0
ChartDataEntry, xIndex: 2, value 10.0
ChartDataEntry, xIndex: 3, value 5.0

Here is what I expect and can achieve with a workaround self.chartView.leftAxis.customAxisMax = 11:

img_0019

@liuxuan30
Copy link
Member

you specified self.chartView.leftAxis.customAxisMax = 10; in your code, and I remember once it is set, the max y axis value will be 10, and the chart outside of the frame will be clipped out:

// make sure the graph values and grid cannot be drawn outside the content-rect
CGContextClipToRect(context, _viewPortHandler.contentRect)
...
renderer?.drawData(context: context)
...
// Removes clipping rectangle
CGContextRestoreGState(context)

But you said sometimes max value doesn't show on the graph even it was shown before the update, you have to check your max value and the customAxisMax.

@yas375
Copy link
Contributor Author

yas375 commented Sep 23, 2015

@liuxuan30 thanks for looking into it! I've noticed the problem after upgrading to the latest ios-charts. So I thought that maybe this is a regression.

Before the last upgrade of ios-charts version used in our app I was using b68481e and here is how it looks like with the same set of data:

2015-09-23_0046

I also set customAxisMax = 10 and you can see that the circle on the max value on the graph is completely visible.

@liuxuan30
Copy link
Member

I tried it on ChartsDemo line chart view controller, with commit 7b85077 (latest before today)

_chartView.leftAxis.customAxisMax = 10;
    NSMutableArray *xVals = [[NSMutableArray alloc] init];

    [xVals addObject:@"1442246400000"];
    [xVals addObject:@"1442419200000"];
    [xVals addObject:@"1442505600000"];
    [xVals addObject:@"1442764800000"];
    [xVals addObject:@"1442851200000"];

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

    [yVals addObject:[[ChartDataEntry alloc] initWithValue:0 xIndex:0]];
    [yVals addObject:[[ChartDataEntry alloc] initWithValue:2 xIndex:1]];
    [yVals addObject:[[ChartDataEntry alloc] initWithValue:10 xIndex:2]];
    [yVals addObject:[[ChartDataEntry alloc] initWithValue:7 xIndex:3]];
    [yVals addObject:[[ChartDataEntry alloc] initWithValue:3 xIndex:4]];

    LineChartDataSet *set1 = [[LineChartDataSet alloc] initWithYVals:yVals label:@"DataSet 1"];

    set1.lineWidth = 1.75;
    set1.circleRadius = 3.0;
    [set1 setColor:[UIColor orangeColor]];
    [set1 setCircleColor:UIColor.whiteColor];
    set1.highlightColor = UIColor.whiteColor;
    set1.drawValuesEnabled = NO;

it looks fine to me, the top value 10's circle is visible too:
10

@yas375
Copy link
Contributor Author

yas375 commented Sep 24, 2015

@liuxuan30 thanks for the help! I'll look closer into this in next few days. I'll try to localize since what ios-charts library I've started to get the different behavior and/or maybe will create a demo app or a unit test. Thanks again!

@liuxuan30
Copy link
Member

No problem!

@yas375
Copy link
Contributor Author

yas375 commented Sep 26, 2015

I've tried to reproduce the problem and can't reproduce this anymore. Weird... I'll keep an eye on this.

Xuan, thanks a lot for your time! 👍

@yas375 yas375 closed this as completed Sep 26, 2015
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