Created
April 25, 2021 22:38
-
-
Save ilamanov/0ca6af0bd552477cad397ca8b210cb33 to your computer and use it in GitHub Desktop.
Creating SwiftPieChart: inner circle
This file contains 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 | |
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) | |
} | |
} | |
.background(self.backgroundColor) | |
.foregroundColor(Color.white) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment