Last active
September 4, 2022 20:43
-
-
Save SahilMutualMobile/aca67f631be20a98be0021c042b25090 to your computer and use it in GitHub Desktop.
SwiftChart_Rectanglechart
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 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