Skip to content

Instantly share code, notes, and snippets.

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