5

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

Arda Oğul Üçpınar
  • 881
  • 1
  • 14
  • 38

1 Answers1

5

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

AlexSmet
  • 2,141
  • 1
  • 13
  • 18
  • that's a good answer. You can choose the same color as the background under the graph and then everything will look good. But what if there is a gradient or a picture under the graph? – Leon Jakonda Dec 10 '21 at 16:43