Refactor chart data generation in EnergyConsumptionPerDeviceChart for improved readability and maintainability

This commit is contained in:
Faris Armoush
2025-05-04 10:47:39 +03:00
parent bafd2b4d13
commit 24c30ddcb5

View File

@ -15,37 +15,15 @@ class EnergyConsumptionPerDeviceChart extends StatelessWidget {
lineTouchData: EnergyManagementChartsHelper.lineTouchData(),
lineBarsData: [
_buildChartBar(
spots: const [
FlSpot(1, 100),
FlSpot(2, 200),
FlSpot(3, 300),
FlSpot(4, 400),
FlSpot(5, 500),
FlSpot(6, 600),
FlSpot(7, 700),
FlSpot(8, 800),
FlSpot(9, 900),
FlSpot(10, 1000),
FlSpot(11, 1100),
FlSpot(12, 1200),
spots: [
for (var i = 0; i < 12; i++) FlSpot(i.toDouble(), (i + 1) * 100),
],
color: Colors.amber,
),
_buildChartBar(
color: Colors.red,
spots: const [
FlSpot(1, 100),
FlSpot(2, 300),
FlSpot(3, 400),
FlSpot(4, 500),
FlSpot(5, 600),
FlSpot(6, 700),
FlSpot(7, 800),
FlSpot(8, 900),
FlSpot(9, 1000),
FlSpot(10, 1100),
FlSpot(11, 1200),
FlSpot(12, 1300),
spots: [
for (var i = 0; i < 12; i++) FlSpot(i.toDouble(), (i + 1) * 110),
],
),
],