SwiftUI BarChart area spacing - Stack Overflow

I have a BarChart made with the SwiftUI Chart API. The bar is pretty close to what I want it to look li

I have a BarChart made with the SwiftUI Chart API. The bar is pretty close to what I want it to look like, but the last details elude me. Here's the current version of the chart.

What I want is to have the bars closer together in order to create some space on the outside of the bars. To be clear, I want the tick lines to remain where they are, just having the bars "tighter". (I want to create space where the black circles are).

Here's the part of the code that I think is relevant:

Chart {
    ForEach(chartData) { data in
        BarMark(x: .value("X value", data.x),
                y: .value("Y value", data.y),
                width: 30)
               .annotation(position: .automatic, alignment: .top) {
                   Text("\(data.y)")
                }
                .clipShape(RoundedRectangle(cornerRadius: 8))
                }

        RuleMark(y: .value("average", averageMark))
            .lineStyle(StrokeStyle(lineWidth: 2, dash: [5, 5]))
            .annotation(position: .top,
                        alignment: .trailing,
                        spacing: 0.0) {
                    Text("★")
                }
        }
    // more Chart code
    }
}

Code is simplified: I omitted the x and y axis builders and styling.

Another thing that would be nice is if I could have the '*' (which is the RuleMark) outside of the chart.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745667185a4639189.html

相关推荐

  • SwiftUI BarChart area spacing - Stack Overflow

    I have a BarChart made with the SwiftUI Chart API. The bar is pretty close to what I want it to look li

    5小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信