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

Line chart with blank data show Y axis label incorrect on iPhone 5 #2583

Closed
ybqboy opened this issue Jul 7, 2017 · 3 comments
Closed

Line chart with blank data show Y axis label incorrect on iPhone 5 #2583

ybqboy opened this issue Jul 7, 2017 · 3 comments

Comments

@ybqboy
Copy link

ybqboy commented Jul 7, 2017

I met this issue, when I create a line chart with blank data, only on iPhone 5, it shows like this
img_0001
as you can see, the Y axis label are all in the corner.
I debugged into the code and found it seems like there is an issue in here, the trans got two NAN values.
image
image

one more thing, if has data, the issue gone and everything seems good. and on iPhone 6 and iPhone 7 everything is fine.

@ybqboy
Copy link
Author

ybqboy commented Jul 11, 2017

can anybody help to check this issue?
also with blank data, the chart will crash if the scale is enabled. so am i wrong to use the blank data chart? here is my code

_chartView.delegate = self;

_chartView.chartDescription.enabled = NO;

_chartView.dragEnabled = YES;
[_chartView setScaleEnabled:YES];
_chartView.pinchZoomEnabled = NO;
_chartView.drawGridBackgroundEnabled = NO;
_chartView.highlightPerDragEnabled = YES;
_chartView.scaleYEnabled = NO;

_chartView.backgroundColor = UIColor.whiteColor;

_chartView.legend.enabled = NO;
_chartView.maxVisibleCount = 4000;


ChartXAxis *xAxis = _chartView.xAxis;
xAxis.labelPosition = XAxisLabelPositionBottom;
xAxis.labelFont = [UIFont fontWithName:@"HelveticaNeue-Light" size:10.f];
xAxis.labelTextColor = [UIColor colorWithRed:255/255.0 green:192/255.0 blue:56/255.0 alpha:1.0];
xAxis.drawAxisLineEnabled = NO;
xAxis.drawGridLinesEnabled = NO;
xAxis.centerAxisLabelsEnabled = YES;
xAxis.granularity = 180.0;
xAxis.valueFormatter = [[DateValueFormatter alloc] init];

NoOverlappingLabelsXAxisRenderer *render = [[NoOverlappingLabelsXAxisRenderer alloc] initWithViewPortHandler:_chartView.viewPortHandler xAxis:_chartView.xAxis transformer:_chartView.xAxisRenderer.transformer];
_chartView.xAxisRenderer = render;


ChartYAxis *leftAxis = _chartView.leftAxis;
leftAxis.labelFont = [UIFont fontWithName:@"HelveticaNeue-Light" size:12.f];
leftAxis.labelTextColor = [UIColor colorWithRed:51/255.0 green:181/255.0 blue:229/255.0 alpha:1.0];
leftAxis.drawGridLinesEnabled = YES;
leftAxis.granularityEnabled = YES;
leftAxis.axisMinimum = 0;
leftAxis.axisMaximum = 25;
leftAxis.labelCount = 5;

_chartView.rightAxis.enabled = NO;

_chartView.legend.form = ChartLegendFormLine;

LineChartData *data = [[LineChartData alloc] initWithDataSets:@[]];
_chartView.data = data;

thanks

@liuxuan30 liuxuan30 reopened this Jul 17, 2017
@liuxuan30
Copy link
Member

liuxuan30 commented Jul 17, 2017

I checked what you said, with Line Chart in ChartsDemo:

On iPhone 5S (which works perfect with empty data sets):
image

On iPhone 5:
image

So I suspect it's due to 32bit and 64bit precising issue, as CGFloat is Float on 32bit device, while it's Double on 64bit device.

It seems you should come up with a workaround for iPhone 5 only, like manually use Dbouble to recalcuate the matrix and feed _matrixValueToPx with correct values.

But before this, what's the population of your app using iPhone 5? It already 4 gens after iPhone 5 and to us, it's just as ancient as iPhone 4S. Ask yourself do you really need to support them?

@aelam
Copy link
Contributor

aelam commented Nov 20, 2018

have you fixed this? I've got this problem too.

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

3 participants