プラグインのchartsで折れ線グラフを使用して
日々の体重を記録するアプリを作っているのですが、
グラフの日付の部分はで
日付は表示できるのですが、
その下に月を表示する方法がわからないです。
わかる方がいましたら教えていたでだきたいです
override func viewDidLoad() { super.viewDidLoad() var lineChartEntry = [ChartDataEntry]() var days:[String] = ["1", "2", "3", "4", "5", "6", "7"] for i in 0 ..< 6 { let chartData = ChartDataEntry(x: Double(i), y: Double(0.4)) lineChartEntry.append(chartData) } let lineChartDataSet = LineChartDataSet(entries: lineChartEntry, label: "nil") lineChartDataSet.axisDependency = .left lineChartDataSet.setColor(#colorLiteral(red: 1, green: 0.6304908395, blue: 0.7219088078, alpha: 1)) lineChartDataSet.setCircleColor(#colorLiteral(red: 1, green: 0.6304908395, blue: 0.7219088078, alpha: 1)) // our circle will be dark red lineChartDataSet.lineWidth = 2.0 lineChartDataSet.circleRadius = 3.0 // the radius of the node circle lineChartDataSet.fillAlpha = 1 let rect = CGRect(x:0, y: 60, width: self.view.frame.width, height: self.view.frame.height - 150) lineChartView = LineChartView(frame: rect) lineChartView.delegate = self lineChartView.data = LineChartData(dataSet: lineChartDataSet) lineChartView.xAxis.valueFormatter = IndexAxisValueFormatter(values: days) lineChartView.xAxis.drawGridLinesEnabled = true lineChartView.xAxis.avoidFirstLastClippingEnabled = true lineChartView.xAxis.labelPosition = .bottom lineChartView.xAxis.axisMinimum = Double(0) lineChartView.leftAxis.labelTextColor = #colorLiteral(red: 1, green: 0.6304908395, blue: 0.7219088078, alpha: 1) //タップ lineChartView.highlightPerTapEnabled = true //背景 lineChartView.drawGridBackgroundEnabled = true lineChartView.rightAxis.drawGridLinesEnabled = false lineChartView.rightAxis.drawAxisLineEnabled = false lineChartView.rightAxis.drawLabelsEnabled = false lineChartView.leftAxis.drawAxisLineEnabled = false lineChartView.leftAxis.drawGridLinesEnabled = false lineChartView.pinchZoomEnabled = false lineChartView.doubleTapToZoomEnabled = false lineChartView.legend.enabled = false lineChartView.setVisibleXRangeMaximum(10.0) lineChartView.xAxis.axisMaximum = Double(10.0) lineChartView.moveViewToX(Double(self.period)) lineChartView.dragEnabled = true lineChartView.doubleTapToZoomEnabled = false var goal = "goal:5kg" let limitLine = ChartLimitLine(limit: Double(5.0), label: goal) limitLine.lineColor = #colorLiteral(red: 0.2108310461, green: 0.7607958913, blue: 0.7475245595, alpha: 1) limitLine.lineDashLengths = [4] limitLine.labelPosition = .topLeft lineChartView.leftAxis.addLimitLine(limitLine) view.addSubview(lineChartView) }
あなたの回答
tips
プレビュー