mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +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(
|
return BarChart(
|
||||||
BarChartData(
|
BarChartData(
|
||||||
maxY: 100.1,
|
maxY: 100.1,
|
||||||
|
alignment: BarChartAlignment.start,
|
||||||
gridData: EnergyManagementChartsHelper.gridData(
|
gridData: EnergyManagementChartsHelper.gridData(
|
||||||
horizontalInterval: 20,
|
horizontalInterval: 20,
|
||||||
),
|
),
|
||||||
|
@ -62,9 +62,11 @@ class _AnalyticsPageState extends State<AnalyticsPage> {
|
|||||||
),
|
),
|
||||||
BlocProvider(
|
BlocProvider(
|
||||||
create: (context) => TotalEnergyConsumptionBloc(
|
create: (context) => TotalEnergyConsumptionBloc(
|
||||||
|
DividedTotalEnergyConsumptionDecorator(
|
||||||
RemoteTotalEnergyConsumptionService(_httpService),
|
RemoteTotalEnergyConsumptionService(_httpService),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
BlocProvider(
|
BlocProvider(
|
||||||
create: (context) => EnergyConsumptionByPhasesBloc(
|
create: (context) => EnergyConsumptionByPhasesBloc(
|
||||||
RemoteEnergyConsumptionByPhasesService(_httpService),
|
RemoteEnergyConsumptionByPhasesService(_httpService),
|
||||||
@ -145,6 +147,7 @@ class _AnalyticsPageFormState extends State<AnalyticsPageForm> {
|
|||||||
context.read<SpaceTreeBloc>().add(InitialEvent());
|
context.read<SpaceTreeBloc>().add(InitialEvent());
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return WebScaffold(
|
return WebScaffold(
|
||||||
|
@ -38,7 +38,7 @@ class AnalyticsEnergyManagementView extends StatelessWidget {
|
|||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: _padding,
|
padding: _padding,
|
||||||
height: MediaQuery.sizeOf(context).height * 1,
|
height: MediaQuery.sizeOf(context).height * 1.05,
|
||||||
child: const Column(
|
child: const Column(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
|
@ -9,22 +9,24 @@ class TotalEnergyConsumptionChart extends StatelessWidget {
|
|||||||
|
|
||||||
final List<EnergyDataModel> chartData;
|
final List<EnergyDataModel> chartData;
|
||||||
|
|
||||||
|
static const _leftTitlesInterval = 5.0;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: LineChart(
|
child: LineChart(
|
||||||
LineChartData(
|
LineChartData(
|
||||||
maxY: chartData.isEmpty
|
maxY: chartData.isNotEmpty
|
||||||
? null
|
? chartData.map((e) => e.value).reduce((a, b) => a > b ? a : b) +
|
||||||
: chartData.map((e) => e.value).reduce((a, b) => a > b ? a : b) + 250,
|
_leftTitlesInterval
|
||||||
|
: null,
|
||||||
clipData: const FlClipData.vertical(),
|
clipData: const FlClipData.vertical(),
|
||||||
titlesData: EnergyManagementChartsHelper.titlesData(
|
titlesData: EnergyManagementChartsHelper.titlesData(
|
||||||
context,
|
context,
|
||||||
leftTitlesInterval: 500,
|
leftTitlesInterval: _leftTitlesInterval,
|
||||||
),
|
),
|
||||||
gridData: EnergyManagementChartsHelper.gridData().copyWith(
|
gridData: EnergyManagementChartsHelper.gridData().copyWith(
|
||||||
checkToShowHorizontalLine: (value) => true,
|
checkToShowHorizontalLine: (value) => true,
|
||||||
horizontalInterval: 500,
|
horizontalInterval: _leftTitlesInterval,
|
||||||
),
|
),
|
||||||
borderData: EnergyManagementChartsHelper.borderData(),
|
borderData: EnergyManagementChartsHelper.borderData(),
|
||||||
lineTouchData: EnergyManagementChartsHelper.lineTouchData(),
|
lineTouchData: EnergyManagementChartsHelper.lineTouchData(),
|
||||||
|
@ -18,6 +18,7 @@ class OccupancyChart extends StatelessWidget {
|
|||||||
return BarChart(
|
return BarChart(
|
||||||
BarChartData(
|
BarChartData(
|
||||||
maxY: 100.001,
|
maxY: 100.001,
|
||||||
|
alignment: BarChartAlignment.start,
|
||||||
gridData: EnergyManagementChartsHelper.gridData().copyWith(
|
gridData: EnergyManagementChartsHelper.gridData().copyWith(
|
||||||
checkToShowHorizontalLine: (value) => true,
|
checkToShowHorizontalLine: (value) => true,
|
||||||
horizontalInterval: 20,
|
horizontalInterval: 20,
|
||||||
|
@ -59,3 +59,23 @@ abstract final class _TotalEnergyConsumptionResponseMapper {
|
|||||||
}).toList();
|
}).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: [
|
children: [
|
||||||
Expanded(child: SpaceTreeView(
|
Expanded(child: SpaceTreeView(
|
||||||
onSelect: () {
|
onSelect: () {
|
||||||
|
context.read<DeviceManagementBloc>().add(ResetFilters());
|
||||||
context.read<DeviceManagementBloc>().add(FetchDevices(context));
|
context.read<DeviceManagementBloc>().add(FetchDevices(context));
|
||||||
},
|
},
|
||||||
)),
|
)),
|
||||||
|
@ -277,6 +277,32 @@ class SmartPowerDeviceControl extends StatelessWidget
|
|||||||
totalConsumption: 10000,
|
totalConsumption: 10000,
|
||||||
date: blocProvider.formattedDate,
|
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),
|
selectedDays: List.filled(7, false),
|
||||||
functionOn: false,
|
functionOn: false,
|
||||||
isEditing: false,
|
isEditing: false,
|
||||||
countdownRemaining: Duration.zero,
|
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
emit(ScheduleLoaded(
|
emit(ScheduleLoaded(
|
||||||
|
Reference in New Issue
Block a user