Skip to content

Commit

Permalink
UPDATE GRAPH VISUAL
Browse files Browse the repository at this point in the history
  • Loading branch information
Shayokh144 committed Sep 11, 2024
1 parent 4257644 commit bc218e5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ struct LineChartScreen: View {
AxisTick()
AxisValueLabel() {
if let date = value.as(Date.self) {
if viewModel.selectedChartOption.value == LineChartOption.last2Months.value {
if viewModel.selectedChartOption.value == LineChartOption.last2Months.value ||
viewModel.selectedChartOption.value == LineChartOption.last2Weeks.value {
Text(DateFormatter.dayMonthYearShort.string(from: date))
.rotationEffect(.degrees(-90))
.padding(.bottom, 20.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ final class LineChartViewModel: ObservableObject {
@Published var chartXAxisValues: [Date] = []
@Published var chartOptions: [String] = []
@Published var selectedChartOption: LineChartOption = .allYear
@Published var viewModelData: LineChartViewModelData
private var years: [String] = []

let viewModelData: LineChartViewModelData

init(lineChartViewModelData: LineChartViewModelData) {
uiModels = []
viewModelData = lineChartViewModelData
Expand Down Expand Up @@ -131,7 +130,7 @@ final class LineChartViewModel: ObservableObject {
} else if selectedChartOption.value == LineChartOption.allMonthlyAverage.value {
dayInterval = 32
} else if selectedChartOption.value == LineChartOption.last2Weeks.value {
dayInterval = 2
dayInterval = 1
dateFormat = ""
}
var currentDate = firstDate
Expand All @@ -145,6 +144,10 @@ final class LineChartViewModel: ObservableObject {
}
}

// UPDATE TIME FRAME

viewModelData.timeFrame = "\(DateFormatter.dayMonthYearShort.string(from: firstDate)) to \(DateFormatter.dayMonthYearShort.string(from: lastDate))"

// UPDATE UI DATA
let uiModel = LineChartDataSeries(
type: "\(selectedChartOption.value) \(dateFormat)",
Expand Down Expand Up @@ -199,7 +202,7 @@ final class LineChartViewModel: ObservableObject {
struct LineChartViewModelData {

let chartName: String
let timeFrame: String
var timeFrame: String
let weightUnitText: String
let currencyUnitText: String
let dataSource: String
Expand Down

0 comments on commit bc218e5

Please sign in to comment.