Removing Grid Lines from Charts in SwiftUI

Hi,

I have created a line graph using LineMark in Charts, which by default includes grid lines and axes lines. My requirement is to remove the grid lines but retain the axes lines and the values.

I have tried the following code:

.chartXAxis {
                    AxisMarks(preset: .extended, values: .stride(by: 2), stroke: StrokeStyle(lineWidth: 0))
}

This is removing grid lines as well as axes lines.

How to retain axes lines while removing grid lines ?

Try creating custom axis marks as descried in Customizing axes in Swift Charts article and only specify the AxisValueLabel

Thank you, this worked fine.

Removing Grid Lines from Charts in SwiftUI
 
 
Q