admin管理员组文章数量:1026989
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.
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.
本文标签: SwiftUI BarChart area spacingStack Overflow
版权声明:本文标题:SwiftUI BarChart area spacing - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745667184a2162243.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论