Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Sources/SwiftUICharts/PieChart/PieChartRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import SwiftUI

struct PieChartData {
public struct PieChartData {
var label: String = ""
var value: Double
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/SwiftUICharts/PieChart/PieChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public struct PieChartView : View {
@State private var showValue = false
@State private var currentValue: PieChartData = PieChartData(value: 0) {
didSet{
if(oldValue != self.currentValue && self.showValue) {
if(oldValue.label != self.currentValue.label && self.showValue) {
HapticFeedback.playSelection()
}
}
Expand All @@ -38,7 +38,7 @@ public struct PieChartView : View {
}
self.dropShadow = dropShadow!
self.valueSpecifier = valueSpecifier!
self.showPercentage = showPercentage
self.showPercentage = showPercentage!
}

public var body: some View {
Expand All @@ -54,7 +54,7 @@ public struct PieChartView : View {
.font(.headline)
.foregroundColor(self.style.textColor)
}else{
Text("\(self.currentValue.label) \(self.currentValue, specifier: self.valueSpecifier)\(self.showPercentage ? "%" : "")")
Text("\(self.currentValue.label) \(self.currentValue.value, specifier: self.valueSpecifier)\(self.showPercentage ? "%" : "")")
.font(.headline)
.foregroundColor(self.style.textColor)
}
Expand All @@ -80,7 +80,7 @@ public struct PieChartView : View {
#if DEBUG
struct PieChartView_Previews : PreviewProvider {
static var previews: some View {
PieChartView(data:[56,78,53,65,54], title: "Title", legend: "Legend")
PieChartView(data:[PieChartData(label: "Q1", value: 56), PieChartData(label: "Q2", value: 78), PieChartData(label: "Q3", value: 53), PieChartData(label: "Q4", value: 65), PieChartData(label: "Q5", value: 54)], title: "Title", legend: "Legend")
}
}
#endif