Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SahilMutualMobile/5dd167f747b8ada1b128af7c9ef25c0e to your computer and use it in GitHub Desktop.
Save SahilMutualMobile/5dd167f747b8ada1b128af7c9ef25c0e to your computer and use it in GitHub Desktop.
SwiftChart_Barchart
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