Skip to content

Commit 6dc76cd

Browse files
committed
Now clears chart markers on viewDidDisappear
1 parent 70bedfc commit 6dc76cd

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

WooCommerce/Classes/ViewRelated/Dashboard/MyStore/ChartMarker.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import Foundation
22
import Charts
33

4-
/// This class is a custom view which is displayed over a chart element (e.g. a Bar) when it is highlighted. It
5-
/// basically is a duplicate of the `BalloonMarker` class found in the Charts demo project.
4+
5+
/// This class is a custom view which is displayed over a chart element (e.g. a Bar) when it is highlighted.
66
///
77
/// See: https://github.com/danielgindi/Charts/blob/master/ChartsDemo-iOS/Swift/Components/BalloonMarker.swift
88
///

WooCommerce/Classes/ViewRelated/Dashboard/MyStore/PeriodDataViewController.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ class PeriodDataViewController: UIViewController, IndicatorInfoProvider {
7575
super.viewDidAppear(animated)
7676
reloadAllFields()
7777
}
78+
79+
override func viewDidDisappear(_ animated: Bool) {
80+
super.viewDidDisappear(animated)
81+
clearChartMarkers()
82+
}
7883
}
7984

8085

@@ -176,7 +181,7 @@ extension PeriodDataViewController: ChartViewDelegate {
176181
func chartValueSelected(_ chartView: ChartViewBase, entry: ChartDataEntry, highlight: Highlight) {
177182
guard entry.y != 0.0 else {
178183
// Do not display the marker if the Y-value is zero
179-
chartView.highlightValue(nil, callDelegate: false)
184+
clearChartMarkers()
180185
return
181186
}
182187

@@ -209,8 +214,7 @@ extension PeriodDataViewController: IAxisValueFormatter {
209214
}
210215
case .week:
211216
if let periodDate = DateFormatter.Stats.statsWeekFormatter.date(from: item.period) {
212-
let firstMonday = Calendar.current.date(byAdding: .day, value: 1, to: periodDate) ?? periodDate
213-
dateString = DateFormatter.Charts.chartsWeekFormatter.string(from: firstMonday)
217+
dateString = DateFormatter.Charts.chartsWeekFormatter.string(from: periodDate)
214218
}
215219
case .month:
216220
if let periodDate = DateFormatter.Stats.statsMonthFormatter.date(from: item.period) {
@@ -292,6 +296,10 @@ private extension PeriodDataViewController {
292296
if lastUpdated != nil { lastUpdated.text = summaryDateUpdated }
293297
}
294298

299+
func clearChartMarkers() {
300+
barChartView.highlightValue(nil, callDelegate: false)
301+
}
302+
295303
func generateBarDataSet() -> BarChartData? {
296304
guard let orderStats = orderStats, let statItems = orderStats.items, !statItems.isEmpty else {
297305
return nil

WooCommerce/Classes/ViewRelated/Dashboard/MyStore/StoreStatsViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ private extension StoreStatsViewController {
180180
static let quantityDefaultForDay = 30
181181
static let quantityDefaultForWeek = 13
182182
static let quantityDefaultForMonth = 12
183-
static let quantityDefaultForYear = 10
183+
static let quantityDefaultForYear = 5
184184
}
185185

186186
enum TabStrip {

0 commit comments

Comments
 (0)