gianni gianni - 5 months ago 36
Swift Question

ios Swift Chart issue

I use Charts iOS library(https://github.com/danielgindi/Charts) and I have this code :

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
}


and I get this :

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

My problem is this :

I want to delete the grid on background(vertical and horizontal lines) but I dont be able because I dont find anything in the official library documentation.

Can you help me?

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

will do the job.

Comments