Created
April 25, 2021 22:48
-
-
Save ilamanov/d7308524ab4b40c96e7d62348dc9fa03 to your computer and use it in GitHub Desktop.
Creating SwiftPieChart: render rows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var body: some View { | |
| GeometryReader { geometry in | |
| VStack{ | |
| ZStack{ | |
| ForEach(0..<self.values.count){ i in | |
| PieSliceView(pieSliceData: self.slices[i]) | |
| } | |
| .frame(width: geometry.size.width, height: geometry.size.width) | |
| Circle() | |
| .fill(self.backgroundColor) | |
| .frame(width: geometry.size.width * innerRadiusFraction, height: geometry.size.width * innerRadiusFraction) | |
| VStack { | |
| Text("Total") | |
| .font(.title) | |
| .foregroundColor(Color.gray) | |
| Text(String(values.reduce(0, +))) | |
| .font(.title) | |
| } | |
| } | |
| PieChartRows(colors: self.colors, names: self.names, values: self.values.map { String($0) }, percents: self.values.map { String(format: "%.0f%%", $0 * 100 / self.values.reduce(0, +)) }) | |
| } | |
| .background(self.backgroundColor) | |
| .foregroundColor(Color.white) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment