IOS-Charts set maximum visible x axis values IOS-Charts set maximum visible x axis values swift swift

IOS-Charts set maximum visible x axis values


I finally got it!

The correct answer is:

chart.setVisibleXRangeMaximum(5)

This however needs to be set after the data has been set in the chart (not in a configure before)

This did the trick for me


You should set the X axis's labelCount property of the chart view.In objc,like this

_chartView.xAxis.labelCount = 5;

Swift

chartView.xAxis.labelCount = 5


Here is my finding!!

  1. you don't need to really use label countif you are using DefaultAxisValueFormatter, NEVER use this. a lot of errors pop ! just use no2.

  2. chart.setVisibleXRangeMaximum(number) will do.please put this after chart data setting here you can see detail

    combinedChartView.data = combineData. //this need to come firstcombinedChartView.setVisibleXRangeMaximum(2) //after data setting