带有valueFormatter的Swift Charts模块

时间:2016-04-12 14:34:59

标签: ios swift ios-charts

我在Swift中使用Charts,我的x轴是一个月[0,0.5,1.5,...,240]的数组,但我想在x轴上显示的是几年,所以我的新x轴将是[0.0,1,2,3 ......,20];我使用

lineChartView.xAxis.setLabelsToSkip(23)

现在我一直坚持使用格式化部分我不知道如何将x数组格式化为整数和多年。

1 个答案:

答案 0 :(得分:0)

以下是我用来绘制图表的内容,我不知道如何使用:

class Employee(models.Model):
    user = models.OneToOneField(User)
    department = models.CharField(max_length=100)

>>> u = User.objects.get(username='fsmith')
>>> freds_department = u.employee.department

我尝试使用其他解决方案中提到的覆盖功能,但它没有调用。

lineChartView.xAxis.valueFormatter?.stringForXValue(Int, original: String, viewPortHandler: lineChartView.viewPortHandler)