Created
September 4, 2022 20:22
-
-
Save SahilMutualMobile/5dd167f747b8ada1b128af7c9ef25c0e to your computer and use it in GitHub Desktop.
SwiftChart_Barchart
This file contains 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
import SwiftUI | |
import Charts | |
struct Barchart: View { | |
@Binding var timing: TimingType | |
var data: [RestaurantSales] | |
var body: some View { | |
VStack(alignment : .leading) { | |
Chart(data) { series in | |
ForEach(series.itemSales) { item in | |
BarMark( | |
x: .value("Day", series.weekday.rawValue), | |
y: .value("Sales", item.sales) | |
) | |
.foregroundStyle(by: .value("Food", item.foodItemName.rawValue)) | |
} | |
} | |
} | |
.frame(height: 300) | |
.padding() | |
} | |
} | |
struct Barchart_Previews: PreviewProvider { | |
static var previews: some View { | |
Barchart(timing: .constant(.Morning), data: morningSales) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment