@@ -53,6 +53,13 @@ class PeriodDataViewController: UIViewController, IndicatorInfoProvider {
5353
5454 // MARK: - Computed Properties
5555
56+ private var currencySymbol : String {
57+ guard let code = orderStats? . currencyCode else {
58+ return String ( )
59+ }
60+ return MoneyFormatter ( ) . currencySymbol ( currencyCode: code) ?? String ( )
61+ }
62+
5663 private var summaryDateUpdated : String {
5764 if let lastUpdatedDate = lastUpdatedDate {
5865 return String . localizedStringWithFormat ( NSLocalizedString ( " Updated %@ " ,
@@ -172,6 +179,7 @@ private extension PeriodDataViewController {
172179 barChartView. noDataFont = StyleManager . chartLabelFont
173180 barChartView. noDataTextColor = StyleManager . wooSecondary
174181 barChartView. extraRightOffset = Constants . chartExtraRightOffset
182+ barChartView. extraTopOffset = Constants . chartExtraTopOffset
175183 barChartView. delegate = self
176184
177185 let xAxis = barChartView. xAxis
@@ -193,15 +201,14 @@ private extension PeriodDataViewController {
193201 yAxis. labelTextColor = StyleManager . wooSecondary
194202 yAxis. axisLineColor = StyleManager . wooGreyBorder
195203 yAxis. gridColor = StyleManager . wooGreyBorder
196- yAxis. gridLineDashLengths = Constants . chartXAxisDashLengths
197- yAxis. axisLineDashPhase = Constants . chartXAxisDashPhase
198204 yAxis. zeroLineColor = StyleManager . wooGreyBorder
199205 yAxis. drawLabelsEnabled = true
200206 yAxis. drawGridLinesEnabled = true
201207 yAxis. drawAxisLineEnabled = false
202208 yAxis. drawZeroLineEnabled = true
203209 yAxis. axisMinimum = Constants . chartYAxisMinimum
204210 yAxis. valueFormatter = self
211+ yAxis. setLabelCount ( 3 , force: true )
205212 }
206213}
207214
@@ -257,7 +264,7 @@ extension PeriodDataViewController: IAxisValueFormatter {
257264 return " "
258265 } else {
259266 yAxisMaximum = value. friendlyString ( )
260- return yAxisMaximum
267+ return currencySymbol + yAxisMaximum
261268 }
262269 }
263270 }
@@ -319,9 +326,8 @@ private extension PeriodDataViewController {
319326 var totalRevenueText = Constants . placeholderText
320327 if let orderStats = orderStats {
321328 totalOrdersText = Double ( orderStats. totalOrders) . friendlyString ( )
322- let currencySymbol = orderStats. currencySymbol
323329 let totalRevenue = orderStats. totalSales. friendlyString ( )
324- totalRevenueText = " \( currencySymbol) \( totalRevenue) "
330+ totalRevenueText = currencySymbol + totalRevenue
325331 }
326332 ordersData. text = totalOrdersText
327333 revenueData. text = totalRevenueText
@@ -364,16 +370,18 @@ private extension PeriodDataViewController {
364370 }
365371
366372 var barCount = 0
373+ var barColors : [ UIColor ] = [ ]
367374 var dataEntries : [ BarChartDataEntry ] = [ ]
368375 statItems. forEach { ( item) in
369376 let entry = BarChartDataEntry ( x: Double ( barCount) , y: item. totalSales)
370- entry. accessibilityValue = " \( item. period) : \( orderStats. currencySymbol) \( item. totalSales. friendlyString ( ) ) "
377+ entry. accessibilityValue = " \( item. period) : \( currencySymbol) \( item. totalSales. friendlyString ( ) ) "
378+ barColors. append ( barColor ( for: item. period) )
371379 dataEntries. append ( entry)
372380 barCount += 1
373381 }
374382
375383 let dataSet = BarChartDataSet ( values: dataEntries, label: " Data " )
376- dataSet. setColor ( StyleManager . wooCommerceBrandColor )
384+ dataSet. colors = barColors
377385 dataSet. highlightEnabled = true
378386 dataSet. highlightColor = StyleManager . wooAccent
379387 dataSet. highlightAlpha = Constants . chartHighlightAlpha
@@ -403,6 +411,16 @@ private extension PeriodDataViewController {
403411 }
404412 return dateString
405413 }
414+
415+ func barColor( for period: String ) -> UIColor {
416+ guard granularity == . day,
417+ let periodDate = DateFormatter . Stats. statsDayFormatter. date ( from: period) ,
418+ Calendar . current. isDateInWeekend ( periodDate) else {
419+ return StyleManager . wooCommerceBrandColor
420+ }
421+
422+ return StyleManager . wooGreyMid
423+ }
406424}
407425
408426
@@ -414,14 +432,13 @@ private extension PeriodDataViewController {
414432
415433 static let chartAnimationDuration : TimeInterval = 0.75
416434 static let chartExtraRightOffset : CGFloat = 25.0
435+ static let chartExtraTopOffset : CGFloat = 20.0
417436 static let chartHighlightAlpha : CGFloat = 1.0
418437
419438 static let chartMarkerInsets : UIEdgeInsets = UIEdgeInsets ( top: 5.0 , left: 2.0 , bottom: 5.0 , right: 2.0 )
420439 static let chartMarkerMinimumSize : CGSize = CGSize ( width: 50.0 , height: 30.0 )
421440 static let chartMarkerArrowSize : CGSize = CGSize ( width: 8 , height: 6 )
422441
423- static let chartXAxisDashLengths : [ CGFloat ] = [ 5.0 , 5.0 ]
424- static let chartXAxisDashPhase : CGFloat = 0.0
425442 static let chartXAxisGranularity : Double = 1.0
426443 static let chartYAxisMinimum : Double = 0.0
427444 }
0 commit comments