mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
Divide energy consumption chart values by hundred (#333)
<!-- Thanks for contributing! Provide a description of your changes below and a general summary in the title Please look at the following checklist to ensure that your PR can be accepted quickly: --> ## Description Divide energy consumption chart values by hundred ## Type of Change <!--- Put an `x` in all the boxes that apply: --> - [ ] ✨ New feature (non-breaking change which adds functionality) - [ ] 🛠️ Bug fix (non-breaking change which fixes an issue) - [x] ❌ Breaking change (fix or feature that would cause existing functionality to change) - [ ] 🧹 Code refactor - [ ] ✅ Build configuration change - [ ] 📝 Documentation - [ ] 🗑️ Chore
This commit is contained in:
@ -20,6 +20,7 @@ class AqiDistributionChart extends StatelessWidget {
|
||||
return BarChart(
|
||||
BarChartData(
|
||||
maxY: 100.1,
|
||||
alignment: BarChartAlignment.start,
|
||||
gridData: EnergyManagementChartsHelper.gridData(
|
||||
horizontalInterval: 20,
|
||||
),
|
||||
|
@ -62,7 +62,9 @@ class _AnalyticsPageState extends State<AnalyticsPage> {
|
||||
),
|
||||
BlocProvider(
|
||||
create: (context) => TotalEnergyConsumptionBloc(
|
||||
RemoteTotalEnergyConsumptionService(_httpService),
|
||||
DividedTotalEnergyConsumptionDecorator(
|
||||
RemoteTotalEnergyConsumptionService(_httpService),
|
||||
),
|
||||
),
|
||||
),
|
||||
BlocProvider(
|
||||
@ -145,6 +147,7 @@ class _AnalyticsPageFormState extends State<AnalyticsPageForm> {
|
||||
context.read<SpaceTreeBloc>().add(InitialEvent());
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WebScaffold(
|
||||
|
@ -38,7 +38,7 @@ class AnalyticsEnergyManagementView extends StatelessWidget {
|
||||
return SingleChildScrollView(
|
||||
child: Container(
|
||||
padding: _padding,
|
||||
height: MediaQuery.sizeOf(context).height * 1,
|
||||
height: MediaQuery.sizeOf(context).height * 1.05,
|
||||
child: const Column(
|
||||
children: [
|
||||
Expanded(
|
||||
|
@ -9,22 +9,24 @@ class TotalEnergyConsumptionChart extends StatelessWidget {
|
||||
|
||||
final List<EnergyDataModel> chartData;
|
||||
|
||||
static const _leftTitlesInterval = 5.0;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Expanded(
|
||||
child: LineChart(
|
||||
LineChartData(
|
||||
maxY: chartData.isEmpty
|
||||
? null
|
||||
: chartData.map((e) => e.value).reduce((a, b) => a > b ? a : b) + 250,
|
||||
maxY: chartData.isNotEmpty
|
||||
? chartData.map((e) => e.value).reduce((a, b) => a > b ? a : b) +
|
||||
_leftTitlesInterval
|
||||
: null,
|
||||
clipData: const FlClipData.vertical(),
|
||||
titlesData: EnergyManagementChartsHelper.titlesData(
|
||||
context,
|
||||
leftTitlesInterval: 500,
|
||||
leftTitlesInterval: _leftTitlesInterval,
|
||||
),
|
||||
gridData: EnergyManagementChartsHelper.gridData().copyWith(
|
||||
checkToShowHorizontalLine: (value) => true,
|
||||
horizontalInterval: 500,
|
||||
horizontalInterval: _leftTitlesInterval,
|
||||
),
|
||||
borderData: EnergyManagementChartsHelper.borderData(),
|
||||
lineTouchData: EnergyManagementChartsHelper.lineTouchData(),
|
||||
|
@ -18,6 +18,7 @@ class OccupancyChart extends StatelessWidget {
|
||||
return BarChart(
|
||||
BarChartData(
|
||||
maxY: 100.001,
|
||||
alignment: BarChartAlignment.start,
|
||||
gridData: EnergyManagementChartsHelper.gridData().copyWith(
|
||||
checkToShowHorizontalLine: (value) => true,
|
||||
horizontalInterval: 20,
|
||||
|
@ -59,3 +59,23 @@ abstract final class _TotalEnergyConsumptionResponseMapper {
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
|
||||
class DividedTotalEnergyConsumptionDecorator
|
||||
implements TotalEnergyConsumptionService {
|
||||
const DividedTotalEnergyConsumptionDecorator(this._decoratee);
|
||||
|
||||
final TotalEnergyConsumptionService _decoratee;
|
||||
@override
|
||||
Future<List<EnergyDataModel>> load(
|
||||
GetTotalEnergyConsumptionParam param,
|
||||
) async {
|
||||
final result = await _decoratee.load(param);
|
||||
final dividedResult = result.map((e) {
|
||||
return EnergyDataModel(
|
||||
date: e.date,
|
||||
value: e.value / 100,
|
||||
);
|
||||
});
|
||||
return dividedResult.toList();
|
||||
}
|
||||
}
|
||||
|
@ -68,6 +68,7 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
|
||||
children: [
|
||||
Expanded(child: SpaceTreeView(
|
||||
onSelect: () {
|
||||
context.read<DeviceManagementBloc>().add(ResetFilters());
|
||||
context.read<DeviceManagementBloc>().add(FetchDevices(context));
|
||||
},
|
||||
)),
|
||||
|
@ -277,6 +277,32 @@ class SmartPowerDeviceControl extends StatelessWidget
|
||||
totalConsumption: 10000,
|
||||
date: blocProvider.formattedDate,
|
||||
),
|
||||
EnergyConsumptionPage(
|
||||
formattedDate:
|
||||
'${blocProvider.dateTime!.day}/${blocProvider.dateTime!.month}/${blocProvider.dateTime!.year} ${blocProvider.endChartDate}',
|
||||
onTap: () {
|
||||
blocProvider.add(SelectDateEvent(context: context));
|
||||
},
|
||||
widget: blocProvider.dateSwitcher(),
|
||||
chartData: blocProvider.energyDataList.isNotEmpty
|
||||
? blocProvider.energyDataList
|
||||
: [
|
||||
EnergyData('12:00 AM', 4.0),
|
||||
EnergyData('01:00 AM', 6.5),
|
||||
EnergyData('02:00 AM', 3.8),
|
||||
EnergyData('03:00 AM', 3.2),
|
||||
EnergyData('04:00 AM', 6.0),
|
||||
EnergyData('05:00 AM', 3.4),
|
||||
EnergyData('06:00 AM', 5.2),
|
||||
EnergyData('07:00 AM', 3.5),
|
||||
EnergyData('08:00 AM', 6.8),
|
||||
EnergyData('09:00 AM', 5.6),
|
||||
EnergyData('10:00 AM', 3.9),
|
||||
EnergyData('11:00 AM', 4.0),
|
||||
],
|
||||
totalConsumption: 10000,
|
||||
date: blocProvider.formattedDate,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -232,7 +232,6 @@ class ScheduleBloc extends Bloc<ScheduleEvent, ScheduleState> {
|
||||
selectedDays: List.filled(7, false),
|
||||
functionOn: false,
|
||||
isEditing: false,
|
||||
countdownRemaining: Duration.zero,
|
||||
));
|
||||
} else {
|
||||
emit(ScheduleLoaded(
|
||||
|
Reference in New Issue
Block a user