2017-11-11 19 views
1

私は2つのデータセットを持つ次の折れ線グラフを持っています。 1つのデータセットは左側のyAxに依存し、他方のデータセットは右側のyAxisに依存する。ios-chartsを使用して、同じ行に左右の軸を揃える方法は?

ここでは、両方とも同じ行にゼロの値を設定します。 他の値は整列されていません。 どうすればいいですか?あなたが持っているので

let speedLine = LineChartDataSet(values: speedEntries, label: "Speed") 
    speedLine.colors = [UIColor.white] 
    speedLine.drawCirclesEnabled = false 
    speedLine.axisDependency = .left 

    let powerLine = LineChartDataSet(values: powerEntries, label: "Power") 
    powerLine.colors = [UIColor.green] 
    powerLine.drawCirclesEnabled = false 
    powerLine.axisDependency = .right 

    let data = LineChartData() 
    data.addDataSet(speedLine) 
    data.addDataSet(powerLine) 

    chartView.data = data 
    chartView.xAxis.labelTextColor = UIColor.white 
    chartView.xAxis.labelCount = 20 
    chartView.leftAxis.labelTextColor = UIColor.white 
    chartView.rightAxis.labelTextColor = UIColor.green 
    chartView.legend.textColor = UIColor.white 
    chartView.rightAxis.axisMinimum = -80.0 

    chartView.chartDescription?.text = "" 

enter image description here

+0

あなたはあなたのコードを共有することはできますか?その後、問題を再現することが可能になります – DevB2F

+0

@ DevB2Fは、質問にコードを追加しました –

答えて

0

コード

chartView.rightAxis.axisMinimum = -80.0 

あなたにもこれを実行する必要があるかもしれません:

chartView.leftAxis.axisMinimum = -80.0 
+0

Didnt work。私は両方を削除して、両方を追加しました。しかし、運がない –

関連する問題