2017-10-03 12 views
0

LineChartViewがあり、xAxisのラベルを表示したい。 私のコードは次のようになります。私はstringForValueが呼​​び出されていることが分かり、デバッガでstringForValueが呼​​び出されてもXAxisラベルが表示されない

chartView.chartDescription?.enabled = false 
    chartView.drawGridBackgroundEnabled = false 
    chartView.dragEnabled = !chartView.isFullyZoomedOut 
    chartView.setScaleEnabled(true) 
    chartView.pinchZoomEnabled = true 
    chartView.setViewPortOffsets(left: 20.0, top: 0.0, right: 20.0, bottom: 0.0) 

    chartView.legend.enabled = true 
    chartView.legend.textColor = legendColor 
    chartView.legend.form = .empty 

    chartView.leftAxis.enabled = false 
    chartView.leftAxis.spaceTop = 0.4 
    chartView.leftAxis.spaceBottom = 0.4 
    chartView.rightAxis.enabled = false 

    chartView.xAxis.enabled = true 
    chartView.xAxis.labelTextColor = UIColor.black 
    chartView.xAxis.valueFormatter = self 
    chartView.xAxis.drawGridLinesEnabled = false 
    chartView.xAxis.drawLabelsEnabled = true 
    chartView.xAxis.drawAxisLineEnabled = false 

    chartView.highlightPerTapEnabled = false 
    chartView.highlightPerDragEnabled = false 

    if lineChartData.entryCount > 0 { 
     chartView.data = lineChartData 
    } 
    chartView.noDataText = NSLocalizedString("No chart data available", comment: String()) 
    chartView.maxVisibleCount = 12 
    chartView.delegate = self 

extension ChartCell: IAxisValueFormatter { 
    func stringForValue(_ value: Double, axis: AxisBase?) -> String { 
     return "foo" 
    } 

}

、しかし描かれたチャートに何のラベルがありません。 line chart without xAxis labels 私はここで紛失しています。

答えて

1

あなたが以下に設定する必要があります。

chartView.xAxis.labelPosition = XAxis.LabelPosition.bottom 
+0

はほとんど、私はそれを動作させるためにXAxis.LabelPosition.bottomInsideを使用する必要がありました。ありがとう!私は多分UITableViewCell内のlineChartViewを持つ私のセットアップは、*ラベルの位置だけで動作するようになると思う – JonEasy

関連する問題