2024-11-18 14:48:54 +08:00
|
|
|
// // ignore_for_file: must_be_immutable
|
2024-08-29 17:45:39 +08:00
|
|
|
|
2024-11-18 14:48:54 +08:00
|
|
|
// import 'package:fl_chart/fl_chart.dart';
|
|
|
|
// import 'package:flutter/material.dart';
|
|
|
|
// import 'package:get/get.dart';
|
|
|
|
// import 'package:intl/intl.dart';
|
2024-08-29 17:45:39 +08:00
|
|
|
|
2024-11-18 14:48:54 +08:00
|
|
|
// import 'component/chart.dart';
|
|
|
|
// import 'process.dart';
|
|
|
|
// import 'real_controller.dart';
|
2024-08-29 17:45:39 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
2024-11-18 14:48:54 +08:00
|
|
|
// // 深度
|
|
|
|
// class RealChart extends StatelessWidget {
|
|
|
|
// RealChart({super.key});
|
|
|
|
// ChartData chartData = ChartData(
|
|
|
|
// [],
|
|
|
|
// );
|
|
|
|
// final RealController realController = Get.put(RealController());
|
|
|
|
// List<ProcessEntity> processList = [];
|
|
|
|
// format(double value, [int fix = 2]) {
|
|
|
|
// return double.parse(value.toStringAsFixed(fix));
|
|
|
|
// }
|
2024-08-29 17:45:39 +08:00
|
|
|
|
2024-11-18 14:48:54 +08:00
|
|
|
// List<ProcessEntity> cache = [];
|
|
|
|
// @override
|
|
|
|
// Widget build(BuildContext context) {
|
|
|
|
// // 显示长度
|
|
|
|
// int showlength = 30;
|
|
|
|
// ever(realController.depth, (newValue) {
|
|
|
|
// ProcessEntity process = ProcessEntity(
|
|
|
|
// recvTime: DateFormat('yyyy-MM-dd HH:mm:ss').format(DateTime.now()),
|
|
|
|
// pileId: realController.pileId.value,
|
|
|
|
// utc: 0,
|
|
|
|
// tid: 100,
|
|
|
|
// toatalFlow1: format(realController.totalFlow1.value),
|
|
|
|
// toatalFlow2: format(realController.totalFlow2.value),
|
|
|
|
// subtotalFlow1: format(realController.subtotalFlow1.value),
|
|
|
|
// subtotalFlow2: format(realController.subtotalFlow2.value),
|
|
|
|
// depth: format(realController.depth.value),
|
|
|
|
// );
|
2024-08-29 17:45:39 +08:00
|
|
|
|
2024-11-18 14:48:54 +08:00
|
|
|
// processList.add(process);
|
2024-08-29 17:45:39 +08:00
|
|
|
|
2024-11-18 14:48:54 +08:00
|
|
|
// if (realController.sliderTime != null) {
|
|
|
|
// if (DateTime.now().difference(realController.sliderTime!).inSeconds >
|
|
|
|
// 10) {
|
|
|
|
// realController.updateProcessList(processList);
|
|
|
|
// realController.updateSlider(processList.length.toDouble(), false);
|
|
|
|
// } else {
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
// } else {
|
|
|
|
// realController.updateProcessList(processList);
|
|
|
|
// if (realController.startIndex.value != processList.length) {
|
|
|
|
// realController.updateSlider(processList.length.toDouble(), false);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// ever(realController.pileId, (newValue) {
|
|
|
|
// ProcessEntity process = ProcessEntity(
|
|
|
|
// recvTime: DateFormat('yyyy-MM-dd HH:mm:ss').format(DateTime.now()),
|
|
|
|
// pileId: realController.pileId.value,
|
|
|
|
// utc: 0,
|
|
|
|
// tid: 100,
|
|
|
|
// toatalFlow1: format(realController.totalFlow1.value),
|
|
|
|
// toatalFlow2: format(realController.totalFlow2.value),
|
|
|
|
// subtotalFlow1: format(realController.subtotalFlow1.value),
|
|
|
|
// subtotalFlow2: format(realController.subtotalFlow2.value),
|
|
|
|
// depth: format(realController.depth.value),
|
|
|
|
// );
|
|
|
|
// processList.length = 0;
|
|
|
|
// processList.add(process);
|
|
|
|
// realController.updateProcessList(processList.toList());
|
|
|
|
// realController.startIndex.value = 0;
|
|
|
|
// });
|
2024-08-29 17:45:39 +08:00
|
|
|
|
2024-11-18 14:48:54 +08:00
|
|
|
// List<Widget> chartTitleWidget = chartData.chartTitleWeidget();
|
|
|
|
// Widget chartWidget(List<ProcessEntity> processList) {
|
|
|
|
// int startIndex = 0;
|
2024-08-29 17:45:39 +08:00
|
|
|
|
2024-11-18 14:48:54 +08:00
|
|
|
// if ((realController.startIndex.value + showlength) < processList.length &&
|
|
|
|
// realController.startIndex.value != 0) {
|
|
|
|
// startIndex = realController.startIndex.value;
|
|
|
|
// } else {
|
|
|
|
// startIndex = ((processList.length - showlength < 0)
|
|
|
|
// ? 0
|
|
|
|
// : (processList.length - showlength));
|
|
|
|
// }
|
|
|
|
// int endIndex = startIndex + showlength > processList.length
|
|
|
|
// ? processList.length
|
|
|
|
// : startIndex + showlength;
|
|
|
|
// ChartData chartData = ChartData(
|
|
|
|
// processList.sublist(startIndex, endIndex),
|
|
|
|
// );
|
|
|
|
// return LineChart(chartData.lineChart);
|
|
|
|
// }
|
2024-08-29 17:45:39 +08:00
|
|
|
|
2024-11-18 14:48:54 +08:00
|
|
|
// return Column(
|
|
|
|
// children: [
|
|
|
|
// Row(
|
|
|
|
// mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
// children: chartTitleWidget,
|
|
|
|
// ),
|
|
|
|
// Expanded(
|
|
|
|
// flex: 1,
|
|
|
|
// child: Obx(
|
|
|
|
// () => SizedBox(child: chartWidget(realController.processList))))
|
|
|
|
// ],
|
|
|
|
// );
|
|
|
|
// }
|
|
|
|
// }
|