Skip to content

Commit 4c17cb9

Browse files
committed
differenceText + filterDimension for analytics
1 parent 6c88be1 commit 4c17cb9

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

WordPress/Classes/ViewRelated/Stats/Insights/ViewsVisitors/ViewsVisitorsLineChartCell.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,21 @@ struct StatsSegmentedControlData {
66
var segmentPrevData: Int
77
var segmentDataStub: String?
88
var difference: Int
9+
var differenceText: String
910
var differencePercent: Int
1011
var date: Date?
1112
var period: StatsPeriodUnit?
1213
var analyticsStat: WPAnalyticsStat?
1314

1415
private(set) var accessibilityHint: String?
1516

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) {
1718
self.segmentTitle = segmentTitle
1819
self.segmentData = segmentData
1920
self.segmentPrevData = segmentPrevData
2021
self.segmentDataStub = segmentDataStub
2122
self.difference = difference
23+
self.differenceText = differenceText
2224
self.differencePercent = differencePercent
2325
self.date = date
2426
self.period = period
@@ -27,7 +29,7 @@ struct StatsSegmentedControlData {
2729
}
2830

2931
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)
3133
let attributedString = NSMutableAttributedString(string: differenceText)
3234

3335
let str = attributedString.string as NSString
@@ -121,8 +123,8 @@ class ViewsVisitorsLineChartCell: StatsBaseCell, NibLoadable {
121123
self.period = period
122124
self.xAxisDates = xAxisDates
123125

124-
configureChartView()
125126
setupSegmentedControl()
127+
configureChartView()
126128
updateLabels()
127129
}
128130

@@ -201,8 +203,10 @@ private extension ViewsVisitorsLineChartCell {
201203
analyticsGranularity: period?.analyticsGranularityLine,
202204
indexToHighlight: 0,
203205
xAxisDates: xAxisDates)
204-
let chartView = StatsLineChartView(configuration: configuration, delegate: statsLineChartViewDelegate)
205206

207+
let statsInsightsFilterDimension: StatsInsightsFilterDimension = selectedSegmentIndex == 0 ? .views : .visitors
208+
209+
let chartView = StatsLineChartView(configuration: configuration, delegate: statsLineChartViewDelegate, statsInsightsFilterDimension: statsInsightsFilterDimension)
206210

207211
resetChartContainerView()
208212
chartContainerView.addSubview(chartView)

0 commit comments

Comments
 (0)