@@ -16,7 +16,8 @@ public struct PieChartView : View {
1616 public var formSize : CGSize
1717 public var dropShadow : Bool
1818 public var valueSpecifier : String
19- public var showPercentage : Bool
19+ public var prefix : String
20+ public var postfix : String
2021
2122 @State private var showValue = false
2223 @State private var currentValue : PieChartData = PieChartData ( value: 0 ) {
@@ -27,7 +28,7 @@ public struct PieChartView : View {
2728 }
2829 }
2930
30- public init ( data: [ PieChartData ] , title: String , legend: String ? = nil , style: ChartStyle = Styles . pieChartStyleOne, form: CGSize ? = ChartForm . medium, dropShadow: Bool ? = true , valueSpecifier: String ? = " %.1f " , showPercentage : Bool ? = false ) {
31+ public init ( data: [ PieChartData ] , title: String , legend: String ? = nil , style: ChartStyle = Styles . pieChartStyleOne, form: CGSize ? = ChartForm . medium, dropShadow: Bool ? = true , valueSpecifier: String ? = " %.1f " , prefix : String ? = " " , postfix : String ? = " " ) {
3132 self . data = data
3233 self . title = title
3334 self . legend = legend
@@ -39,6 +40,8 @@ public struct PieChartView : View {
3940 self . dropShadow = dropShadow!
4041 self . valueSpecifier = valueSpecifier!
4142 self . showPercentage = showPercentage!
43+ self . prefix = prefix!
44+ self . postfix = postfix!
4245 }
4346
4447 public var body : some View {
@@ -54,7 +57,7 @@ public struct PieChartView : View {
5457 . font ( . headline)
5558 . foregroundColor ( self . style. textColor)
5659 } else {
57- Text ( " \( self . currentValue. label) \( self . currentValue. value, specifier: self . valueSpecifier) \( self . showPercentage ? " % " : " " ) " )
60+ Text ( " \( self . currentValue. label) \( self . prefix ) \( self . currentValue. value, specifier: self . valueSpecifier) \( self . postfix ) " )
5861 . font ( . headline)
5962 . foregroundColor ( self . style. textColor)
6063 }
0 commit comments