Created
September 14, 2020 04:19
-
-
Save prafullakumar/19a1f9b886304c31792a27603cf00693 to your computer and use it in GitHub Desktop.
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
struct InnerCircle: Shape { | |
let ratio: CGFloat | |
func path(in rect: CGRect) -> Path { | |
let center = CGPoint.init(x: (rect.origin.x + rect.width)/2, y: (rect.origin.y + rect.height)/2) | |
let radii = min(center.x, center.y) * ratio | |
let path = Path { p in | |
p.addArc(center: center, | |
radius: radii, | |
startAngle: Angle(degrees: 0), | |
endAngle: Angle(degrees: 360), | |
clockwise: true) | |
p.addLine(to: center) | |
} | |
return path | |
} | |
} | |
struct DonutChart: View { | |
@State private var selectedCell: UUID = UUID() | |
let dataModel: ChartDataModel | |
let onTap: (ChartCellModel?) -> () | |
var body: some View { | |
ZStack { | |
PieChart(dataModel: dataModel, onTap: onTap) | |
InnerCircle(ratio: 1/3).foregroundColor(.white) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment