@@ -66,6 +66,7 @@ class PeriodDataViewController: UIViewController, IndicatorInfoProvider {
6666 }
6767
6868 let dataSet = BarChartDataSet ( values: dataEntries, label: " Data " )
69+ dataSet. setColor ( StyleManager . wooCommerceBrandColor)
6970 return BarChartData ( dataSet: dataSet)
7071 }
7172
@@ -148,33 +149,36 @@ private extension PeriodDataViewController {
148149 barChartView. noDataText = NSLocalizedString ( " No data available " , comment: " Text displayed when no data is available for revenue chart. " )
149150 barChartView. noDataFont = StyleManager . chartLabelFont
150151 barChartView. noDataTextColor = StyleManager . wooSecondary
152+ barChartView. extraRightOffset = Constants . chartExtraRightOffset
151153
152154 let xAxis = barChartView. xAxis
153155 xAxis. labelPosition = . bottom
156+ xAxis. setLabelCount ( 2 , force: true )
154157 xAxis. labelFont = StyleManager . chartLabelFont
155158 xAxis. labelTextColor = StyleManager . wooSecondary
156159 xAxis. axisLineColor = StyleManager . wooGreyBorder
157160 xAxis. gridColor = StyleManager . wooGreyBorder
158161 xAxis. drawLabelsEnabled = true
159162 xAxis. drawGridLinesEnabled = false
160163 xAxis. drawAxisLineEnabled = false
161- xAxis. granularity = 1.0
164+ xAxis. granularity = Constants . chartXAxisGranularity
162165 xAxis. granularityEnabled = true
163- xAxis. setLabelCount ( 2 , force: true )
164166 xAxis. valueFormatter = self
165167
166168 let yAxis = barChartView. leftAxis
167169 yAxis. labelFont = StyleManager . chartLabelFont
168170 yAxis. labelTextColor = StyleManager . wooSecondary
169171 yAxis. axisLineColor = StyleManager . wooGreyBorder
170172 yAxis. gridColor = StyleManager . wooGreyBorder
173+ yAxis. gridLineDashLengths = Constants . chartXAxisDashLengths
174+ yAxis. axisLineDashPhase = Constants . chartXAxisDashPhase
171175 yAxis. zeroLineColor = StyleManager . wooGreyBorder
172- yAxis. valueFormatter = self
173176 yAxis. drawLabelsEnabled = true
174177 yAxis. drawGridLinesEnabled = true
175178 yAxis. drawAxisLineEnabled = false
176179 yAxis. drawZeroLineEnabled = true
177- yAxis. axisMinimum = 0
180+ yAxis. axisMinimum = Constants . chartYAxisMinimum
181+ yAxis. valueFormatter = self
178182 }
179183}
180184
@@ -280,7 +284,12 @@ extension PeriodDataViewController: IAxisValueFormatter {
280284 return " "
281285 }
282286 } else {
283- return value. friendlyString ( )
287+ if value == 0.0 {
288+ // Do not show the 0 label on the Y axis
289+ return " "
290+ } else {
291+ return value. friendlyString ( )
292+ }
284293 }
285294 }
286295}
@@ -290,7 +299,14 @@ extension PeriodDataViewController: IAxisValueFormatter {
290299//
291300private extension PeriodDataViewController {
292301 enum Constants {
293- static let placeholderText = " - "
294- static let chartAnimationDuration = 0.75
302+ static let placeholderText = " - "
303+
304+ static let chartAnimationDuration : TimeInterval = 0.75
305+ static let chartExtraRightOffset : CGFloat = 20.0
306+
307+ static let chartXAxisDashLengths : [ CGFloat ] = [ 5.0 , 5.0 ]
308+ static let chartXAxisDashPhase : CGFloat = 0.0
309+ static let chartXAxisGranularity : Double = 1.0
310+ static let chartYAxisMinimum : Double = 0.0
295311 }
296312}
0 commit comments