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

xAxis gridlines are missing #3451

Closed
JCMcLovin opened this issue May 12, 2018 · 3 comments
Closed

xAxis gridlines are missing #3451

JCMcLovin opened this issue May 12, 2018 · 3 comments

Comments

@JCMcLovin
Copy link
Contributor

JCMcLovin commented May 12, 2018

I'm using Charts 3.1.1 and my line chart will not display enough xAxis gridlines to fill the viewport:

missing_gridlines

I want the chart to always display enough gridlines to fill the viewport like the chart in the Health app does:

healthchart

In my example above I have just one data point and I've set my range to a minimum of 7 hoping it would force 7 xAxis gridlines to always display but it doesn't work:
chartView.setVisibleXRange(minXRange: 7.0, maxXRange: 7.0)

Is this a bug or is there some way to do this that I can't find?

@liuxuan30
Copy link
Member

I'm not sure what's enough xAxis gridlines. besides, have you looked at computeAxisValues too see what's the xaxis entries? the grid lines only draw if there are corresponding entry values

@JCMcLovin
Copy link
Contributor Author

@liuxuan30, Let me say it another way. Do you see in the second screenshot above (from Apple's Health app) how the chart has 8 vertical xAxis gridlines even though there's only one dataEntry?. That's what I want my chart to do. The chart should always show 'enough' gridlines to fill the viewport. If I've configured my chart to show a maximum of 8 data points, if I have less than 8 data points, there should still be 8 gridlines.

I have looked at computeAxisValues for hours and hours and I can't figure out how it actually works. It seems to be entirely dependent on the data values which suggests you must have a data point for each possible x value and that wouldn't make any sense.

Hope that helps.

@liuxuan30
Copy link
Member

how can it be? if you have seen computeAxisValues, you know it takes min/max values from your x data range and compute the axis.entries, which are x value labels. So if you only have one data entry, just override the method or provide another way to feed axis.entries with 8 values, you are good to go.

by default, if you only have one entry, the min/max will be +- 1 of your entry. so the range is close. I tried with x = 0, and it gives me 7 vales within [-1, 1]
image

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