diff --git a/lib/pages/analytics/modules/air_quality/widgets/range_of_aqi_chart.dart b/lib/pages/analytics/modules/air_quality/widgets/range_of_aqi_chart.dart index c9c56bdd..a271d154 100644 --- a/lib/pages/analytics/modules/air_quality/widgets/range_of_aqi_chart.dart +++ b/lib/pages/analytics/modules/air_quality/widgets/range_of_aqi_chart.dart @@ -36,36 +36,7 @@ class RangeOfAqiChart extends StatelessWidget { gridData: EnergyManagementChartsHelper.gridData( horizontalInterval: 50, ), - titlesData: EnergyManagementChartsHelper.titlesData(context).copyWith( - leftTitles: AxisTitles( - sideTitles: SideTitles( - reservedSize: 70, - interval: 51, - showTitles: true, - maxIncluded: true, - getTitlesWidget: (value, meta) { - String text; - if (value >= 300) { - text = '300+'; - } else if (value == 255) { - text = '300'; - } else { - text = ((value / 50).round() * 50).toInt().toString(); - } - return Padding( - padding: const EdgeInsetsDirectional.only(end: 12), - child: Text( - text, - style: context.textTheme.bodySmall?.copyWith( - fontSize: 12, - color: ColorsManager.lightGreyColor, - ), - ), - ); - }, - ), - ), - ), + titlesData: _titlesData(context), borderData: EnergyManagementChartsHelper.borderData(), betweenBarsData: [ BetweenBarsData( @@ -148,4 +119,41 @@ class RangeOfAqiChart extends StatelessWidget { ), ); } + + FlTitlesData _titlesData(BuildContext context) { + final titlesData = EnergyManagementChartsHelper.titlesData(context); + return titlesData.copyWith( + leftTitles: titlesData.leftTitles.copyWith( + sideTitles: titlesData.leftTitles.sideTitles.copyWith( + reservedSize: 70, + interval: 51, + maxIncluded: true, + getTitlesWidget: (value, meta) { + String text; + if (value >= 300) { + text = '300+'; + } else if (value == 255) { + text = '300'; + } else { + text = ((value / 50).round() * 50).toInt().toString(); + } + return Padding( + padding: const EdgeInsetsDirectional.only(end: 12), + child: FittedBox( + alignment: AlignmentDirectional.centerStart, + fit: BoxFit.scaleDown, + child: Text( + text, + style: context.textTheme.bodySmall?.copyWith( + fontSize: 12, + color: ColorsManager.lightGreyColor, + ), + ), + ), + ); + }, + ), + ), + ); + } }