ios Charts 3.0 - Align x labels (dates) with plots

后端 未结 4 1754
渐次进展
渐次进展 2020-12-09 20:05

I am having a hard time to migrate library Charts (from Daniel Gindi) from version 2 (Swift 2.3) to 3 (Swift 3).

Basically, I can\'t have the x labels (dates) aligne

4条回答
  •  孤街浪徒
    2020-12-09 20:29

    If you exactly know how many labels you need in the x-axis,you can write this code to solve it.For example,If I need seven labels to appear on the x-axis,Then this should be enough.The reason is the chart library is not properly calculating the intervals between the two x-axis points and hence the plot-label mismatch.When we force the library to plot against the given number of labels,The issue seems to be gone.

     let xAxis = chart.xAxis
     xAxis.centerAxisLabelsEnabled = false
     xAxis.setLabelCount(7, force: true) //enter the number of labels here
    

提交回复
热议问题