ios-charts Draw grid lines only below data

I need to draw grid lines (on line chart) only below the data. I couldn't find an API for it, yet.

Here I drew something showing what I get and what I need:

Top drawing is what I get. Below is what I need. Sorry for awful drawing talent :)

Any suggestions? Thank you.

enter image description here

Upvotes: 5

Views: 1547

Answers (1)

AlexSmet
AlexSmet

Reputation: 2161

Another way. Use fillFormatter to fill the area where you don't want to see grid lines.

I check this code snippet with ChartsDemo-iOS-Swift example. In class LineChart1ViewController I changed part of setDataCount() function. I specifically used white color, so you can see the filled area.

//...
    set1.fillAlpha = 1
    set1.drawFilledEnabled = true
    set1.fillColor = .white
    set1.fillFormatter = DefaultFillFormatter { _,_  -> CGFloat in
        return CGFloat(self.chartView.leftAxis.axisMaximum)
    }
//...

Result

filled area

Upvotes: 5

Related Questions