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 13753938349d..52aa478f590b 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,20 +69,23 @@ class TrafficBarChartViewHolder(parent: ViewGroup) : BlockListItemViewHolder( private fun BarChart.draw(item: BlockListItem.TrafficBarChartItem): 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.size + return dataSet.entryCount } private fun hasData(entries: List) = entries.isNotEmpty() && entries.any { it.value > 0 } - private fun getData(item: BlockListItem.TrafficBarChartItem): List { + private fun getData(item: BlockListItem.TrafficBarChartItem): IBarDataSet { val minColumnCount = 5 val graphWidth = DisplayUtils.pxToDp(chart.context, chart.width) @@ -97,10 +100,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() { 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