From f1dd267262edc1c49c9dfd61d55c66e9a86a12e3 Mon Sep 17 00:00:00 2001 From: Aditi Bhatia Date: Thu, 29 Feb 2024 16:18:09 -0800 Subject: [PATCH 1/4] Fix size issue --- .../refresh/lists/sections/traffic/TrafficBarChartViewHolder.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/traffic/TrafficBarChartViewHolder.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/traffic/TrafficBarChartViewHolder.kt index 92e741fce46d..c874b0407008 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/traffic/TrafficBarChartViewHolder.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/traffic/TrafficBarChartViewHolder.kt @@ -77,7 +77,7 @@ class TrafficBarChartViewHolder(parent: ViewGroup) : BlockListItemViewHolder( configureXAxis(item) invalidate() - return data.dataSets.size + return data.dataSets[0].entryCount } private fun hasData(entries: List) = entries.isNotEmpty() && entries.any { it.value > 0 } From 7d696008435b9f965798803ab3fab187bfb9c2d9 Mon Sep 17 00:00:00 2001 From: Aditi Bhatia Date: Thu, 29 Feb 2024 16:36:58 -0800 Subject: [PATCH 2/4] Simplify getData() function return --- .../lists/sections/traffic/TrafficBarChartViewHolder.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/traffic/TrafficBarChartViewHolder.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/traffic/TrafficBarChartViewHolder.kt index c874b0407008..e8292466e228 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/traffic/TrafficBarChartViewHolder.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/traffic/TrafficBarChartViewHolder.kt @@ -82,7 +82,7 @@ class TrafficBarChartViewHolder(parent: ViewGroup) : BlockListItemViewHolder( private fun hasData(entries: List) = entries.isNotEmpty() && entries.any { it.value > 0 } - private fun getData(item: BlockListItem.BarChartItem): List { + private fun getData(item: BlockListItem.BarChartItem): IBarDataSet { val minColumnCount = 5 val graphWidth = DisplayUtils.pxToDp(chart.context, chart.width) @@ -97,10 +97,8 @@ class TrafficBarChartViewHolder(parent: ViewGroup) : BlockListItemViewHolder( buildEmptyDataSet(chart.context, cutEntries.size) } item.onBarChartDrawn?.invoke(dataSet.entryCount) - val dataSets = mutableListOf() - dataSets.add(dataSet) - return dataSets + return dataSet } private fun configureChartView() { From 7f70160311e4074989bae046e5f9ebdd6a1af8d7 Mon Sep 17 00:00:00 2001 From: Aditi Bhatia Date: Thu, 29 Feb 2024 16:37:45 -0800 Subject: [PATCH 3/4] Update BarChart.draw() function to use simplified dataset --- .../lists/sections/traffic/TrafficBarChartViewHolder.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/traffic/TrafficBarChartViewHolder.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/traffic/TrafficBarChartViewHolder.kt index e8292466e228..29328cff710c 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/traffic/TrafficBarChartViewHolder.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/traffic/TrafficBarChartViewHolder.kt @@ -69,15 +69,18 @@ class TrafficBarChartViewHolder(parent: ViewGroup) : BlockListItemViewHolder( private fun BarChart.draw(item: BlockListItem.BarChartItem): Int { resetChart() + val dataSet = getData(item) + val dataSets = mutableListOf() + dataSets.add(dataSet) - data = BarData(getData(item)) + data = BarData(dataSets) configureChartView() configureYAxis(item) configureXAxis(item) invalidate() - return data.dataSets[0].entryCount + return dataSet.entryCount } private fun hasData(entries: List) = entries.isNotEmpty() && entries.any { it.value > 0 } From 8cae9480e709cde4d7ebdb0720e748decfefa614 Mon Sep 17 00:00:00 2001 From: Aditi Bhatia Date: Fri, 1 Mar 2024 13:37:26 -0800 Subject: [PATCH 4/4] Update parseStatsDate() to use lowerGranularity instead of bar graph granularity --- .../refresh/lists/sections/traffic/TrafficOverviewUseCase.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/traffic/TrafficOverviewUseCase.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/traffic/TrafficOverviewUseCase.kt index 6dd519a3849e..5f2fb3bcad0e 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/traffic/TrafficOverviewUseCase.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/traffic/TrafficOverviewUseCase.kt @@ -282,7 +282,7 @@ class TrafficOverviewUseCase( lowerGranularity ) if (period != null && period != "empty") { - val selectedDate = statsDateFormatter.parseStatsDate(statsGranularity, period) + val selectedDate = statsDateFormatter.parseStatsDate(lowerGranularity, period) selectedDateProvider.selectDate( selectedDate, lowerGranularity