Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 417
Arda Oğul Üçpınar Avatar asked Mar 07 '20 07:03

Arda Oğul Üçpınar


1 Answers

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

like image 51
AlexSmet Avatar answered Nov 12 '22 11:11

AlexSmet