Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Sources/SwiftUICharts/PieChart/PieChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public struct PieChartView : View {
public var formSize:CGSize
public var dropShadow: Bool
public var valueSpecifier:String
public var showPercentage:Bool
public var prefix:String
public var postfix: String

@State private var showValue = false
@State private var currentValue: PieChartData = PieChartData(value: 0) {
Expand All @@ -27,7 +28,7 @@ public struct PieChartView : View {
}
}

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){
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? = ""){
self.data = data
self.title = title
self.legend = legend
Expand All @@ -39,6 +40,8 @@ public struct PieChartView : View {
self.dropShadow = dropShadow!
self.valueSpecifier = valueSpecifier!
self.showPercentage = showPercentage!
self.prefix = prefix!
self.postfix = postfix!
}

public var body: some View {
Expand All @@ -54,7 +57,7 @@ public struct PieChartView : View {
.font(.headline)
.foregroundColor(self.style.textColor)
}else{
Text("\(self.currentValue.label) \(self.currentValue.value, specifier: self.valueSpecifier)\(self.showPercentage ? "%" : "")")
Text("\(self.currentValue.label) \(self.prefix)\(self.currentValue.value, specifier: self.valueSpecifier)\(self.postfix)")
.font(.headline)
.foregroundColor(self.style.textColor)
}
Expand Down