@@ -6,19 +6,21 @@ struct StatsSegmentedControlData {
6
6
var segmentPrevData : Int
7
7
var segmentDataStub : String ?
8
8
var difference : Int
9
+ var differenceText : String
9
10
var differencePercent : Int
10
11
var date : Date ?
11
12
var period : StatsPeriodUnit ?
12
13
var analyticsStat : WPAnalyticsStat ?
13
14
14
15
private( set) var accessibilityHint : String ?
15
16
16
- init ( segmentTitle: String , segmentData: Int , segmentPrevData: Int , difference: Int , segmentDataStub: String ? = nil , date: Date ? = nil , period: StatsPeriodUnit ? = nil , analyticsStat: WPAnalyticsStat ? = nil , accessibilityHint: String ? = nil , differencePercent: Int ) {
17
+ init ( segmentTitle: String , segmentData: Int , segmentPrevData: Int , difference: Int , differenceText : String , segmentDataStub: String ? = nil , date: Date ? = nil , period: StatsPeriodUnit ? = nil , analyticsStat: WPAnalyticsStat ? = nil , accessibilityHint: String ? = nil , differencePercent: Int ) {
17
18
self . segmentTitle = segmentTitle
18
19
self . segmentData = segmentData
19
20
self . segmentPrevData = segmentPrevData
20
21
self . segmentDataStub = segmentDataStub
21
22
self . difference = difference
23
+ self . differenceText = differenceText
22
24
self . differencePercent = differencePercent
23
25
self . date = date
24
26
self . period = period
@@ -27,7 +29,7 @@ struct StatsSegmentedControlData {
27
29
}
28
30
29
31
var attributedDifference : NSAttributedString ? {
30
- let differenceText = String ( format: NSLocalizedString ( " Your last week's %@ are %@ %@ than the previous week. " , comment : " Your last week's stats compared to previous week " ) , segmentTitle . localizedLowercase , differenceLabel, difference < 0 ? NSLocalizedString ( " lower " , comment : " Stats difference is lower " ) : NSLocalizedString ( " higher " , comment : " Stats difference is higher " ) )
32
+ let differenceText = String ( format: differenceText , differenceLabel)
31
33
let attributedString = NSMutableAttributedString ( string: differenceText)
32
34
33
35
let str = attributedString. string as NSString
@@ -121,8 +123,8 @@ class ViewsVisitorsLineChartCell: StatsBaseCell, NibLoadable {
121
123
self . period = period
122
124
self . xAxisDates = xAxisDates
123
125
124
- configureChartView ( )
125
126
setupSegmentedControl ( )
127
+ configureChartView ( )
126
128
updateLabels ( )
127
129
}
128
130
@@ -201,8 +203,10 @@ private extension ViewsVisitorsLineChartCell {
201
203
analyticsGranularity: period? . analyticsGranularityLine,
202
204
indexToHighlight: 0 ,
203
205
xAxisDates: xAxisDates)
204
- let chartView = StatsLineChartView ( configuration: configuration, delegate: statsLineChartViewDelegate)
205
206
207
+ let statsInsightsFilterDimension : StatsInsightsFilterDimension = selectedSegmentIndex == 0 ? . views : . visitors
208
+
209
+ let chartView = StatsLineChartView ( configuration: configuration, delegate: statsLineChartViewDelegate, statsInsightsFilterDimension: statsInsightsFilterDimension)
206
210
207
211
resetChartContainerView ( )
208
212
chartContainerView. addSubview ( chartView)
0 commit comments