Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IOS-Charts set maximum visible x axis values

I'm using ios-charts (https://github.com/danielgindi/Charts). I have a LineChartView with 12 values in the x axis. This however is far too many to see at the same time, so I want to display only 5 and then let the user drag to the right to see the next.

enter image description here

I've tried this:

    let chart = LineChartView()
    chart.dragEnabled = true
    chart.setVisibleXRangeMaximum(5)

    let xAxis = chart.xAxis
    xAxis.axisMinValue = 0
    xAxis.axisMaxValue = 5.0
    xAxis.setLabelsToSkip(0)

But still see all 11 values at the time. How can I only see 5?

like image 223
Jonas Avatar asked Sep 19 '16 14:09

Jonas


1 Answers

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
like image 170
Y.Bi Avatar answered Oct 06 '22 15:10

Y.Bi