{"action":"closed","issue":{"url":"https://api.github.com/repos/danielgindi/Charts/issues/2756","repository_url":"https://api.github.com/repos/danielgindi/Charts","labels_url":"https://api.github.com/repos/danielgindi/Charts/issues/2756/labels{/name}","comments_url":"https://api.github.com/repos/danielgindi/Charts/issues/2756/comments","events_url":"https://api.github.com/repos/danielgindi/Charts/issues/2756/events","html_url":"https://github.com/danielgindi/Charts/issues/2756","id":253583295,"number":2756,"title":"Fill the color between two line charts using IFillFormatter. Help!","user":{"login":"shekhargupta","id":1814709,"avatar_url":"https://avatars1.githubusercontent.com/u/1814709?v=4","gravatar_id":"","url":"https://api.github.com/users/shekhargupta","html_url":"https://github.com/shekhargupta","followers_url":"https://api.github.com/users/shekhargupta/followers","following_url":"https://api.github.com/users/shekhargupta/following{/other_user}","gists_url":"https://api.github.com/users/shekhargupta/gists{/gist_id}","starred_url":"https://api.github.com/users/shekhargupta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shekhargupta/subscriptions","organizations_url":"https://api.github.com/users/shekhargupta/orgs","repos_url":"https://api.github.com/users/shekhargupta/repos","events_url":"https://api.github.com/users/shekhargupta/events{/privacy}","received_events_url":"https://api.github.com/users/shekhargupta/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-08-29T09:16:53Z","updated_at":"2017-08-29T09:25:13Z","closed_at":"2017-08-29T09:25:13Z","body":"```\r\nimport UIKit\r\nimport Charts\r\n\r\nclass ChartsViewController: UIViewController, ChartViewDelegate {\r\n    \r\n    @IBOutlet weak var lineChartView: LineChartView!\r\n    \r\n    let months = [\"Jan\" , \"Feb\", \"Mar\", \"Apr\", \"May\", \"June\", \"July\", \"August\", \"Sept\", \"Oct\", \"Nov\", \"Dec\"]\r\n    \r\n    let dollars1 = [0.0, 150, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000, 2200]\r\n    let dollars2 = [0.0, 100, 300, 500, 700, 900, 1100, 1300, 1500, 1700, 1900, 2100]\r\n    let dollars3 = [0.0, 50, 180, 350, 550, 730, 940, 1150, 1350, 1550, 1750, 1950]\r\n    \r\n    override func viewDidLoad() {\r\n        super.viewDidLoad()\r\n        // 1\r\n        self.lineChartView.delegate = self\r\n        // 2\r\n        self.lineChartView.chartDescription?.text = \"Tap node for details\"\r\n        // 3\r\n        self.lineChartView.chartDescription?.textColor = UIColor.white\r\n        self.lineChartView.gridBackgroundColor = UIColor.darkGray\r\n        // 4\r\n        self.lineChartView.noDataText = \"No data provided\"\r\n        // 5\r\n        \r\n        self.lineChartView.backgroundColor = UIColor.white\r\n        self.lineChartView.drawGridBackgroundEnabled = true\r\n        self.lineChartView.drawBordersEnabled = true\r\n        self.lineChartView.chartDescription?.enabled = false\r\n        self.lineChartView.pinchZoomEnabled = false\r\n        self.lineChartView.dragEnabled = false\r\n\r\n        \r\n        setChartData(months: months)\r\n        \r\n    }\r\n    \r\n    func setChartData(months : [String]) {\r\n        \r\n        // 1 - creating an array of data entries\r\n        var yVals1 : [ChartDataEntry] = [ChartDataEntry]()\r\n        var yVals2 : [ChartDataEntry] = [ChartDataEntry]()\r\n        var yVals3 : [ChartDataEntry] = [ChartDataEntry]()\r\n        \r\n        for i in 0..<months.count {\r\n            yVals1.append(ChartDataEntry(x: Double(i), y: dollars1[i]))\r\n        }\r\n        \r\n        for i in 0..<months.count {\r\n            yVals2.append(ChartDataEntry(x: Double(i), y: dollars2[i]))\r\n        }\r\n        \r\n        for i in 0..<months.count {\r\n            yVals3.append(ChartDataEntry(x: Double(i), y: dollars3[i]))\r\n        }\r\n        \r\n\r\n        // 2 - create a data set with our array\r\n        let set1: LineChartDataSet = LineChartDataSet(values: yVals1, label: \"First Set\")\r\n        set1.axisDependency = .left // Line will correlate with left axis values\r\n        set1.setColor(UIColor.red.withAlphaComponent(0.5)) // our line's opacity is 50%\r\n        set1.drawCirclesEnabled = false\r\n        set1.lineWidth = 2.0\r\n        set1.circleRadius = 0.0 // the radius of the node circle\r\n        set1.fillAlpha = 65 / 255.0\r\n        set1.drawFilledEnabled = true\r\n        set1.fillColor = UIColor.white\r\n        set1.highlightColor = UIColor.white\r\n        set1.drawCircleHoleEnabled = true\r\n        set1.mode = .cubicBezier\r\n//        set1.fillFormatter = MyFillFormatter(chartView: self.lineChartView)\r\n        set1.fillFormatter = DefaultFillFormatter(block: { (dataSet: ILineChartDataSet, dataProvider: LineChartDataProvider) -> CGFloat in\r\n            return CGFloat(self.lineChartView.leftAxis.axisMinimum)\r\n        })\r\n        \r\n        \r\n        let set2: LineChartDataSet = LineChartDataSet(values: yVals2, label: \"second Set\")\r\n        set2.axisDependency = .left // Line will correlate with left axis values\r\n        set2.setColor(UIColor.green.withAlphaComponent(0.5)) // our line's opacity is 50%\r\n        set2.drawCirclesEnabled = false\r\n//        set2.drawFilledEnabled = true\r\n        set2.lineWidth = 2.0\r\n        set2.circleRadius = 0.0 // the radius of the node circle\r\n        set2.fillAlpha = 65 / 255.0\r\n        set2.drawCirclesEnabled = true\r\n        set2.fillColor = UIColor.green\r\n        set2.highlightColor = UIColor.darkGray\r\n        set2.drawCircleHoleEnabled = true\r\n        set2.mode = .cubicBezier\r\n//        set2.fillFormatter = DefaultFillFormatter(block: { (dataSet: ILineChartDataSet, dataProvider: LineChartDataProvider) -> CGFloat in\r\n//            return CGFloat(set1.yMax)\r\n//        })\r\n\r\n        \r\n        let set3: LineChartDataSet = LineChartDataSet(values: yVals3, label: \"third Set\")\r\n        set3.axisDependency = .left // Line will correlate with left axis values\r\n        set3.setColor(UIColor.yellow.withAlphaComponent(0.5)) // our line's opacity is 50%\r\n        set3.drawCirclesEnabled = false\r\n//        set3.drawFilledEnabled = true\r\n        set3.lineWidth = 2.0\r\n        set3.circleRadius = 0.0 // the radius of the node circle\r\n        set3.fillAlpha = 65 / 255.0\r\n        set3.fillColor = UIColor.yellow\r\n        set3.highlightColor = UIColor.darkGray\r\n        set3.drawCircleHoleEnabled = true\r\n        set3.mode = .cubicBezier\r\n//        set3.fillFormatter = DefaultFillFormatter(block: { (dataSet: ILineChartDataSet, dataProvider: LineChartDataProvider) -> CGFloat in\r\n//            return CGFloat(set2.yMax)\r\n//        })\r\n        \r\n//        set3.fillFormatter = c\r\n        \r\n        //3 - create an array to store our LineChartDataSets\r\n        var dataSets : [LineChartDataSet] = [LineChartDataSet]()\r\n        dataSets.append(set1)\r\n        dataSets.append(set2)\r\n        dataSets.append(set3)\r\n        \r\n        //4 - pass our months in for our x-axis label value along with our dataSets\r\n        let data: LineChartData = LineChartData(dataSets: dataSets)\r\n        data.setValueTextColor(UIColor.clear)\r\n        data.setDrawValues(false)\r\n        \r\n        //5 - finally set our data\r\n        self.lineChartView.data = data\r\n        \r\n        //6 - add x-axis label\r\n        let xaxis = self.lineChartView.xAxis\r\n        xaxis.valueFormatter = MyXAxisFormatter(months)\r\n        \r\n    }\r\n    \r\n}\r\n```\r\nSo, using code fills the area till the axis. Can we just fill the area between the line only?\r\n"}}
{"actor":{"display_login":"shekhargupta"}}