2017-12-11 5 views
0

(https://github.com/danielgindi/Charts)을 사용하여 간단한 작은 차트를 만들었습니다. 여기서 줄 자체 옆에있는 모든 것을 제거하려고하지만 하단 제로 축을 제거 할 수는 없습니다. 설명서를 살펴 봤지만 제거 할 수는 없습니까? 당신은 x 축 xAxis.enabled = falseios 차트에서 제로 줄을 제거하십시오.

또는 설정을 해제 할 수

: 그냥 x 축을 숨기려면

enter image description here

차트

class CellChartView: UIView { 

    var lineChart: LineChartView! 

    override init(frame: CGRect) { 
     super.init(frame: frame) 

     self.lineChart = LineChartView() 
     lineChart.backgroundColor = Color.lightTheme.value 
     lineChart.translatesAutoresizingMaskIntoConstraints = false 
     self.lineChart.chartDescription?.text = "" 
     self.lineChart.isUserInteractionEnabled = false 

     self.lineChart.legend.enabled = false 
     self.lineChart.minOffset = 0 

     self.lineChart.drawBordersEnabled = false 
     self.lineChart.drawGridBackgroundEnabled = false 
     self.lineChart.autoScaleMinMaxEnabled = true 

     self.lineChart.rightAxis.enabled = false 

     self.lineChart.leftAxis.enabled = false 
     self.lineChart.leftAxis.drawAxisLineEnabled = false 
     self.lineChart.leftAxis.axisLineColor = UIColor.green 

     self.lineChart.xAxis.drawLabelsEnabled = false 
     self.lineChart.xAxis.drawGridLinesEnabled = false 
     self.lineChart.xAxis.labelPosition = .bottom 
     self.lineChart.xAxis.drawLimitLinesBehindDataEnabled = false 
     self.lineChart.xAxis.enabled = false 

     self.lineChart.xAxis.axisLineColor = UIColor.clear 



     self.addSubview(self.lineChart) 

     lineChart.centerXAnchor.constraint(equalTo: self.centerXAnchor).isActive = true 
     lineChart.topAnchor.constraint(equalTo: self.topAnchor, constant: -1).isActive = true 
     lineChart.widthAnchor.constraint(equalTo: self.widthAnchor).isActive = true 
     lineChart.heightAnchor.constraint(equalTo: self.heightAnchor).isActive = true 
    } 

    required init?(coder aDecoder: NSCoder) { 
     fatalError("init(coder:) has not been implemented") 
    } 

    func setChartData(values: [Double], dates: [String]) { 

     var yValues : [ChartDataEntry] = [ChartDataEntry]() 
     for i in 0 ..< dates.count { 
      yValues.append(ChartDataEntry(x: Double(i + 1), y: values[i])) 
     } 

     let data = LineChartData() 
     let ds = LineChartDataSet(values: yValues, label: "Date") 
     ds.drawCirclesEnabled = false 
     ds.lineWidth = 1 
     ds.drawValuesEnabled = false 

     if (values.first ?? 0.0 > values.last ?? 0.0) { 
      ds.setColor(Color.redColor.value) 
     } else { 
      ds.setColor(Color.greenColor.value) 
     } 


     data.addDataSet(ds) 

     data.setDrawValues(false) 
     self.lineChart.data = data 
    } 

} 

답변

1

는, 나는 두 가지 방법을 참조 xAxis 선 색상이 투명하게 표현됩니다. xAxis.axisLineColor = UIColor.clear

+0

이 두 가지를 모두 시도했지만 아무 작업도 수행하지 않고 줄을 제거하지 않습니다. –

+0

이상합니다. 코드를 사용하려고했지만 LineChartView가 스토리 보드를 통해 만들어졌지만 아래 축이 표시되지 않았습니다. – AlexSmet

+0

전체'UIView' 하위 클래스로 업데이트했습니다. 아마도 이것을 사용하여 재현 할 수 있습니까? 미리 감사드립니다 –