Skip to content

Instantly share code, notes, and snippets.

@ilamanov
Created April 25, 2021 22:38
Show Gist options
  • Save ilamanov/0ca6af0bd552477cad397ca8b210cb33 to your computer and use it in GitHub Desktop.
Save ilamanov/0ca6af0bd552477cad397ca8b210cb33 to your computer and use it in GitHub Desktop.
Creating SwiftPieChart: inner circle
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