1
私の表にDouble値を表示するのではなく、各値の文字列を表示したいと思います。私はまだダブル値から描画するグラフをしたい、しかし、私は代わりに日付の文字列を表示するラベルをしたい。これを行う方法?barChart/swiftでdouble値をStringに変更するにはどうすればよいですか?
私はDaniel Cohen Gindisライブラリを使用しています。
Here is the code for my graph:
import UIKit
import Charts
class ViewController: UIViewController {
@IBOutlet var barChartView: BarChartView!
override func viewDidLoad() {
super.viewDidLoad()
//x line values
let tools = ["Saw","Sissor","Axe"
,"Hammer","Tray"]
//y line values
let values = [1.0,2.0,3.0,4.0,5.0]
setChart(tools, values: values, colors: colors)
}
func setChart(xAxisLabels: [String], values: [Double], colors: [UIColor]){
var dataEntries : [BarChartDataEntry] = []
for i in 0..<xAxisLabels.count {
let dataEntry = BarChartDataEntry(value: values[i], xIndex: i)
dataEntries.append(dataEntry)
}
barChartView.leftAxis.axisMinValue = 0.0
barChartView.leftAxis.axisMaxValue = 14.0
barChartView.data = chartData
}
}
あなたのコードは私のためにコンパイルしていない、あなたはあなたのコードはあなたを助けるために更新することができますか? –