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 a271d154..e0a8107f 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 @@ -65,46 +65,26 @@ class RangeOfAqiChart extends StatelessWidget { } LineChartBarData _buildMinLine() { - return LineChartBarData( - spots: List.generate( - minValues.length, - (i) => FlSpot(i.toDouble(), minValues[i]), - ), - isCurved: true, + return _buildLine( + values: minValues, color: const Color(0xFF93AAFD), - barWidth: 3, - isStrokeCapRound: true, - dotData: _buildDotData(const Color(0xFF023DFE)), - belowBarData: BarAreaData(show: false), + dotColor: const Color(0xFF023DFE), ); } LineChartBarData _buildAverageLine() { - return LineChartBarData( - spots: List.generate( - avgValues.length, - (i) => FlSpot(i.toDouble(), avgValues[i]), - ), - isCurved: true, + return _buildLine( + values: avgValues, color: Colors.white, - barWidth: 3, - dotData: const FlDotData(show: false), - belowBarData: BarAreaData(show: false), + dotColor: null, ); } LineChartBarData _buildMaxLine() { - return LineChartBarData( - spots: List.generate( - maxValues.length, - (i) => FlSpot(i.toDouble(), maxValues[i]), - ), - isCurved: true, + return _buildLine( + values: maxValues, color: const Color(0xFF962DFF), - barWidth: 3, - isStrokeCapRound: true, - dotData: _buildDotData(const Color(0xFF5F00BD)), - belowBarData: BarAreaData(show: false), + dotColor: const Color(0xFF5F00BD), ); } @@ -120,6 +100,26 @@ class RangeOfAqiChart extends StatelessWidget { ); } + LineChartBarData _buildLine({ + required List values, + required Color color, + Color? dotColor, + }) { + return LineChartBarData( + spots: List.generate( + values.length, + (i) => FlSpot(i.toDouble(), values[i]), + ), + isCurved: true, + color: color, + barWidth: 4, + isStrokeCapRound: true, + dotData: + dotColor != null ? _buildDotData(dotColor) : const FlDotData(show: false), + belowBarData: BarAreaData(show: false), + ); + } + FlTitlesData _titlesData(BuildContext context) { final titlesData = EnergyManagementChartsHelper.titlesData(context); return titlesData.copyWith(