UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: Need advise on grid lines displayed in a chart

Forums > SwiftUI

Hello Everyone, I have a chart related question. See thge chart in the image linked below. You can see the horizontal gridlines displayed under each bar. I'd like to get rid of them but I cant figure out how to do that. I've tried to add .chartXAxis(.hidden), that seems to remove them, but it also removes the date from the Y axis. Any ideas?


Thank you for any advise!

  Chart {
            ForEach(last5Crawls) { crawlData in
                    x: .value("Avg. Discovered by Google", crawlData.knownUrls),
                    y: .value("Crawl", crawlData.crawlDateLaunched),
                    width: 20
                .annotation(position: .trailing) {
                    Text("\(crawlData.knownUrls) (\(crawlData.knownUrlsChange, specifier: "%.2f")%)")
                        .font(.system(size: 10, weight: .semibold))
                        .foregroundColor(crawlData.knownUrlsChange < 0 ? .red : .green)
        .frame(minHeight: 180)
            "All Pages": Color.yellow
        .chartLegend(position: .top, alignment: .bottomLeading)


Try this modifier

.chartYAxis {
  AxisMarks(stroke: StrokeStyle(lineWidth: 0))


.chartYAxis {
    AxisMarks { _ in


Genius, pure genius. Thank you @ygeres. Thank you very much!

This worked for me

.chartYAxis {
  AxisMarks(stroke: StrokeStyle(lineWidth: 0))


Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.