Created
September 4, 2022 20:29
-
-
Save SahilMutualMobile/224893cdb9abe2280e39e83cd9b13296 to your computer and use it in GitHub Desktop.
SwiftChart_Linechart
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 Linechart: View { | |
@Binding var timing: TimingType | |
var data: [RestaurantSales] | |
var body: some View { | |
VStack(alignment : .leading) { | |
Chart(data) { series in | |
ForEach(series.itemSales) { item in | |
LineMark( | |
x: .value("Day", series.weekday.rawValue), | |
y: .value("Sales", item.sales) | |
) | |
.foregroundStyle(by: .value("Food", item.foodItemName.rawValue)) | |
.symbol(by: .value("Food", item.foodItemName.rawValue)) | |
} | |
RuleMark( | |
y: .value("Breakeven", 15) | |
) | |
} | |
} | |
.frame(height: 300) | |
.padding() | |
} | |
} | |
struct Linechart_Previews: PreviewProvider { | |
static var previews: some View { | |
Linechart(timing: .constant(.Morning), data: morningSales) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment