如何在 Swift 4 上使用图表在 X 轴上设置名称?

How to set name on X axis Using charts on Swift 4?

这是我的询问(已编辑):

我尝试使用图表绘制月度图形,但在将月份名称放在 X 轴上时遇到一些困难。我的默认值如下图所示: default value

并且在使用了来自 here, I got this

的最高投票答案之后

所以在投入了几个小时但没有结果之后,我想问你是否知道如何获得类似于 this one 的情节。总结一下:

  1. 将月份的名称放在x轴上(垂直的,而不是图中水平的)
  2. 在图形底部绘制月份名称,而不是在默认值上看到的顶部

提前致谢。如果你需要我的一些代码,我可以分享给你。

亲切的问候。

经过反复研究和更好的研究,这是我的问题的答案:

//Give the value of the months to the x axis
    barChart.xAxis.valueFormatter = IndexAxisValueFormatter(values:months)
    barChart.xAxis.granularity = 1

//Position of the x axis, rotation of the labels on the x axis and show all the names of the months consecutively
    barChart.xAxis.labelPosition = XAxis.LabelPosition.bottom
    barChart.xAxis.labelRotationAngle = -90.0
    barChart.xAxis.setLabelCount(counter, force: false)