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

问题描述 投票:0回答:1

这是我的询问(编辑):

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

在使用here最受欢迎的答案之后,我得到了this

因此,在投入了几个小时无用的结果后,我想问你是否知道如何获得类似于this one的情节。总结一下:

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

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

亲切的问候。

charts swift4
1个回答
0
投票

在玩完并进行更好的研究之后,这就是我的问题的答案:

//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)
© www.soinside.com 2019 - 2024. All rights reserved.