Title: How to set the label count for X axis in LineChartView?
Tags: ios;linechart;ios-charts
Question: In my data, I have hundreds of values for the x-axis, but I want to show only 6 or 7 of them at equal intervals so that my whole range of x-axis values are covered, but I am facing an issue as I am not able to show a limited number of values on the x-axis . I tried these
lineChartView.xAxis.spaceMin = 4
lineChartView.xAxis.spaceMax = 7
lineChartView.xAxis.xOffset = 6
lineChartView.xAxis.labelCount = 6
, but it is not working .Here is my screenshot for the display
Comment: Can you show us how you are adding DataSource in charts ?

Comment: @CodeChanger i got it right .I was doing a mistake in adding the data .Thanks :)


Here is another answer: The axis property granularity is used to specify the minimum interval between axis values. The default value is 1. Currently in my app i have it set to 0.5 to force all values to be displayed, but I only have 10 or so on the bduncan@example.org.
chartView.xAxis.granularity = 0.5
Perhaps setting this to a higher value will help you.

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2017:00:06/22/17', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<ios><linechart><ios-charts>', 'Title': 'How to set the label count for X axis in LineChartView?', 'ViewCount': 1162, 'id': 44690555, 'user_AboutMe': '<p>Hands on experience in mobile application development. Machine Learning Enthusiast.</p>\n', 'user_AccountId': 8831296.0, 'user_DisplayName': 'Samarth Kejriwal', 'user_Reputation': 1137.0, 'user_Views': 330.0, 'user_id': 6597572.0}}