iOS-Charts Float to Integer YAxis [英] iOS-Charts Float to Integer YAxis

查看:157
本文介绍了iOS-Charts Float to Integer YAxis的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iOS图表构建图表

I'm building a chart using iOS-charts

我正在尝试将浮点数转换为int,但iOS图表仅允许在数据条目中使用浮点数:

I'm trying to convert the floats into int, but iOS-charts only allows for Floats in the data entry:

      let result = ChartDataEntry(value: Float(month), xIndex: i)

有没有人知道确保只使用整数的方法?

Does anyone know the method for making sure only ints are used?

推荐答案

你只需要调整 NSNumberFormatter ...

You just need to adjust the NSNumberFormatter...

示例:

yAxis.valueFormatter = NSNumberFormatter()
yAxis.valueFormatter.minimumFractionDigits = 0

NSNumberFormatter 是一个非常强大的类,你可以用它做更多的事情。 : - )

NSNumberFormatter is a very powerful class, you can do much much more with it. :-)

这篇关于iOS-Charts Float to Integer YAxis的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆