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/224893cdb9abe2280e39e83cd9b13296 to your computer and use it in GitHub Desktop.
Save SahilMutualMobile/224893cdb9abe2280e39e83cd9b13296 to your computer and use it in GitHub Desktop.
SwiftChart_Linechart
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