IOS charts set the maximum visible x-axis values

I am using ios-charts ( https://github.com/danielgindi/Charts ). I have a LineChartView with 12 x-axis values. This, however, is too much 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 one.

enter image description here

I 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 a time. How can I see only 5?

+4
source share
2 answers

I finally got it!

Correct answer:

chart.setVisibleXRangeMaximum(5)

However, for this it is necessary to install after , the data was installed on the diagram (and not in the setting earlier)

+5

labelCount X . objc,

_chartView.xAxis.labelCount = 5;
0

Source: https://habr.com/ru/post/1655083/


All Articles