2016-03-04 36 views
2

我在2個月後更新了ios-charts到最新的代碼。當我運行代碼時,我看到很多不同之處。用最新的ioscharts顯示條形圖的問題

這是更新庫之前:

enter image description here

更新後:

enter image description here

下面是生成圖表的代碼:

chart.infoTextColor = UIColor.blackColor() 

     chart.backgroundColor = UIColor.whiteColor() 
     chart.descriptionText = "" 
     chart.noDataText = "Loading..." 
     chart.rightAxis.enabled = false 
     chart.xAxis.wordWrapEnabled = true 

     chart.legend.position = .BelowChartCenter; 
     chart.legend.form = .Circle; 
     chart.legend.formSize = 10.0; 
     chart.legend.formToTextSpace = 10.0; 
     chart.legend.xEntrySpace = 4.0; 
     chart.legend.yEntrySpace = 2.0 
     chart.legend.stackSpace = 5.0 
     chart.legend.textColor = UIColor.blueColor() 

     chart.xAxis.gridColor = UIColor.blueColor() 
//  chart.xAxis.axisLineColor = UIColor.blueColor() 

     chart.gridBackgroundColor = UIColor.whiteColor() 
     chart.borderColor = UIColor.redColor() 

//  chart.xAxis.labelHeight = 18 
//  chart.xAxis.labelWidth = 18 
     chart.xAxis.labelPosition = .Bottom; 
     chart.xAxis.drawGridLinesEnabled = false; 

     chart.rightAxis.drawGridLinesEnabled = false; 

     //zooming.. 
     chart.pinchZoomEnabled = false 
     chart.doubleTapToZoomEnabled = false 
     chart.scaleXEnabled = false 
     chart.scaleYEnabled = false 

     //new.. 
     chart.leftAxis.labelPosition = .InsideChart 
chartDataSet.barSpace = 0.38 
+0

看來你有你的代碼有問題。但是,除非我們有[可以重現問題的代碼或信息](http://stackoverflow.com/help/mcve),否則我們無法提供幫助。否則,我們只是盲目猜測。 – gunr2171

+0

這個屏幕截圖只是舊的以及更新的代碼。我爲這兩個圖表傳遞了相同的信息。 – Ash

+0

你能編輯你的文章以包含代碼嗎?你將需要發佈你的設置圖表功能以及數據輸入,數據集等。 – Shen

回答

1

最新版本已經開始DEPR來自startAtZeroEnabled,這似乎是你的情況。

請嘗試設置customAxisMin以獲取已確定的範圍。例如customAxisMin = 0

記得打電話chartView.data = yourData之前設置它,或者你需要specificly調用chartView.notifyDataSetChanged()

+0

謝謝,現在圖表工作正常。我只看到了答案。 – Ash

+0

有沒有什麼方法可以設置每個欄的寬度? – Ash

+0

查看barSpace,並且不要在一個線程中提出無關緊要的問題 – Wingzero