2016-06-17 3 views
2

나는 차트 아이폰 OS 라이브러리 (https://github.com/danielgindi/Charts)를 사용하고이 코드가 있습니다IOS 스위프트 차트 문제는

import UIKit 
import Charts 


    class ChartsViewController: UIViewController , ChartViewDelegate{ 

     var lineChartView: LineChartView? 
     let months = ["Jan" , "Feb", "Mar", "Apr", "May", "June", "July", "August", "Sept", "Oct", "Nov", "Dec"] 
     let dollars1 = [1453.0,2352,5431,1442,5451,6486,1173,5678,9234,1345,9411,2212] 

     override func viewDidLoad() { 
      super.viewDidLoad() 

      self.lineChartView = LineChartView(frame: CGRectMake(50, 70, 300, 300)) 
      self.lineChartView!.delegate = self 
      self.lineChartView!.descriptionText = "Tap node for details" 
      self.lineChartView!.drawGridBackgroundEnabled = false 
      self.lineChartView!.descriptionTextColor = UIColor.whiteColor() 
      self.lineChartView!.noDataText = "No data provided" 
      setChartData(months) 
      self.view.addSubview(self.lineChartView!) 



     } 
     func setChartData(months : [String]) { 

      var yVals1 : [ChartDataEntry] = [ChartDataEntry]() 
      for var i = 0; i < months.count; i++ { 
       yVals1.append(ChartDataEntry(value: dollars1[i], xIndex: i)) 
      } 

      let set1: LineChartDataSet = LineChartDataSet(yVals: yVals1, label: "First Set") 
      set1.lineWidth = 10.0 
      set1.circleRadius = 0.0 // the radius of the node circle 
      set1.fillColor = UIColor.redColor() 
      set1.highlightColor = UIColor.yellowColor() 
      set1.drawCircleHoleEnabled = false 
      set1.drawVerticalHighlightIndicatorEnabled = false 
      var dataSets : [LineChartDataSet] = [LineChartDataSet]() 
      dataSets.append(set1) 
      let data: LineChartData = LineChartData(xVals: months, dataSets: dataSets) 
      data.setValueTextColor(UIColor.whiteColor()) 
      self.lineChartView!.data = data    
     } 

을하고 나는이 얻을 :

:

https://postimg.org/image/6z6nk5nkn/

내 문제는이입니다

배경 (세로 및 가로줄)에서 격자를 삭제하려고하지만 공식 라이브러리 설명서에서 아무 것도 찾을 수 없기 때문에 가능하지 않습니다.

도와 주시겠습니까?

+0

저에게 도움이 될만한 사람이 있습니까? – gianni

답변

1
self.lineChartView.leftAxis.drawGridLinesEnabled = false 
self.lineChartView.xAxis.drawGridLinesEnabled = false 

이 일을 할 것입니다.

+0

감사! 잘 했어 – gianni

1

당신은 그리드를 사용하지 않도록이 코드를 사용할 수 있습니다

lineChartView.xAxis.drawGridLinesEnabled = false 
lineChartView.leftAxis.drawGridLinesEnabled = false 
+0

이 방법을 사용하면 세로선 만 비활성화되지만 가로줄은 비활성화합니까? – gianni

+0

귀하의 방법 으로이 얻을 : https://postimg.org/image/hvca4aoip/ – gianni

+0

오, 미안 해요, 다른 속성을 잊어 버린, 내 대답을 업데이 트했습니다. –