feat:更新图表组件

This commit is contained in:
2026-06-29 21:42:25 +08:00
parent 1953e43ca4
commit 64dbb29ee4
4 changed files with 71 additions and 138 deletions

View File

@@ -1,58 +0,0 @@
import 'dart:io';
import 'package:file_picker/file_picker.dart';
import 'package:minio/io.dart';
import 'package:minio/minio.dart';
import 'file_utils.dart';
class MinIOHelper {
static final MinIOHelper _instance = MinIOHelper._internal();
factory MinIOHelper() => _instance;
final String ip = '14.103.235.151';
final String fileUrl = 'http://14.103.235.151:9100';
MinIOHelper._internal() {
_minio = Minio(
endPoint: ip,
port: 9100,
accessKey: "tHSFfcDW8qpCzKa2Xg6Y",
secretKey: "oq79EeYJ4jdczRp2IHUMCnbKtSw58NgDlG3sOkvX",
useSSL: false,
);
}
late Minio _minio;
Future<String> uploadFile({
required PlatformFile file,
required String bucketName,
Function(double)? onProgress,
}) async {
try {
if (isImageFile(file.name)) {
// 压缩图片
final compressedFile = await compressImage(File(file.path!));
String hashName = await generateMD5HashName(compressedFile.path);
String fileName = '$hashName${getFileExtension(file.name)}';
await _minio.fPutObject(bucketName, fileName, compressedFile.path);
await compressedFile.delete();
return fileName;
} else {
String hashName = await generateMD5HashName(file.path!);
String fileName = '$hashName${getFileExtension(file.name)}';
await _minio.fPutObject(bucketName, fileName, file.path!);
return fileName;
}
} catch (e) {
throw Exception('文件上传失败: $e');
}
}
}

View File

@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_charts/charts.dart'; import 'package:syncfusion_flutter_charts/charts.dart';
import '../models/common_model.dart'; import '../models/common_model.dart';
import 'common_widget.dart';
class StatsCard extends StatelessWidget { class StatsCard extends StatelessWidget {
final String title; final String title;
@@ -21,61 +20,46 @@ class StatsCard extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final colors = Theme.of(context).colorScheme; final colors = Theme.of(context).colorScheme;
return CommonCard( return Row(
child: Row( children: [
children: [ Container(
Container( padding: const EdgeInsets.all(12),
padding: const EdgeInsets.all(12), decoration: BoxDecoration(
decoration: BoxDecoration( color: colors.primary,
color: colors.primary.withAlpha(50), shape: BoxShape.circle,
shape: BoxShape.circle,
),
child: Icon(icon, size: 26, color: colors.primary),
), ),
SizedBox(width: 6), child: Icon(icon, size: 26, color: colors.surface),
Expanded( ),
child: Column( SizedBox(width: 6),
mainAxisAlignment: MainAxisAlignment.center, Expanded(
crossAxisAlignment: CrossAxisAlignment.center, child: Column(
children: [ mainAxisAlignment: MainAxisAlignment.center,
Text( crossAxisAlignment: CrossAxisAlignment.center,
title, children: [
style: TextStyle( Text(
fontSize: 16, title,
color: Colors.grey.shade600, style: Theme.of(context).textTheme.titleMedium,
fontWeight: FontWeight.w500, ),
const SizedBox(height: 6),
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
value,
style: Theme.of(context).textTheme.titleLarge,
), ),
), const SizedBox(width: 4),
const SizedBox(height: 6), Text(
Row( unit,
mainAxisAlignment: MainAxisAlignment.center, style: Theme.of(context).textTheme.bodyMedium,
crossAxisAlignment: CrossAxisAlignment.end, ),
children: [ ],
Text( ),
value, ],
style: TextStyle(
fontSize: 28,
fontWeight: FontWeight.bold,
color: colors.primary,
height: 1.0,
),
),
const SizedBox(width: 4),
Text(
unit,
style: TextStyle(
fontSize: 14,
color: Colors.grey.shade600,
fontWeight: FontWeight.w500,
),
),
],
),
],
),
), ),
], ),
), ],
); );
} }
} }
@@ -111,7 +95,12 @@ class LineChart extends StatelessWidget {
// title: ChartTitle(text: ''), // title: ChartTitle(text: ''),
// X轴配置类别轴 // X轴配置类别轴
primaryXAxis: CategoryAxis(majorGridLines: MajorGridLines(width: 0)), primaryXAxis: CategoryAxis(
majorGridLines: const MajorGridLines(width: 0),
labelIntersectAction: AxisLabelIntersectAction.hide,
interval: (data.length > 6) ? 3 : 1, // 根据数据量动态算
edgeLabelPlacement: EdgeLabelPlacement.shift,
),
// Y轴配置数值轴 // Y轴配置数值轴
// primaryYAxis: NumericAxis(title: AxisTitle(text: '$yAxisName$unit')), // primaryYAxis: NumericAxis(title: AxisTitle(text: '$yAxisName$unit')),
@@ -438,8 +427,9 @@ class RankChart extends StatelessWidget {
const SizedBox(height: 3), const SizedBox(height: 3),
_buildChartDivider(context), _buildChartDivider(context),
const SizedBox(height: 3), const SizedBox(height: 3),
Expanded( ListView.builder(
child: ListView.builder( shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: data.length, itemCount: data.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
final item = data[index]; final item = data[index];
@@ -483,7 +473,7 @@ class RankChart extends StatelessWidget {
), ),
); );
}, },
)) )
]); ]);
} }
} }
@@ -492,7 +482,8 @@ Widget _buildChartTitle(BuildContext context, String title, IconData icon) {
return Row( return Row(
children: [ children: [
Icon(icon, color: Theme.of(context).colorScheme.primary), Icon(icon, color: Theme.of(context).colorScheme.primary),
Text(title), SizedBox(width: 4),
Text(title, style: Theme.of(context).textTheme.titleMedium),
], ],
); );
} }

View File

@@ -229,10 +229,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: fake_async name: fake_async
sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc" sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.3.2" version: "1.3.3"
ffi: ffi:
dependency: transitive dependency: transitive
description: description:
@@ -404,10 +404,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: intl name: intl
sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.19.0" version: "0.20.2"
io: io:
dependency: transitive dependency: transitive
description: description:
@@ -444,26 +444,26 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker name: leak_tracker
sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "10.0.8" version: "11.0.2"
leak_tracker_flutter_testing: leak_tracker_flutter_testing:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker_flutter_testing name: leak_tracker_flutter_testing
sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573 sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "3.0.9" version: "3.0.10"
leak_tracker_testing: leak_tracker_testing:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker_testing name: leak_tracker_testing
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "3.0.1" version: "3.0.2"
lints: lints:
dependency: transitive dependency: transitive
description: description:
@@ -508,10 +508,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.16.0" version: "1.17.0"
mime: mime:
dependency: transitive dependency: transitive
description: description:
@@ -652,10 +652,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: shared_preferences name: shared_preferences
sha256: "6e8bf70b7fef813df4e9a36f658ac46d107db4b4cfe1048b477d4e453a8159f5" sha256: c3025c5534b01739267eb7d76959bbc25a6d10f6988e1c2a3036940133dd10bf
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.5.3" version: "2.5.5"
shared_preferences_android: shared_preferences_android:
dependency: transitive dependency: transitive
description: description:
@@ -809,10 +809,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.7.4" version: "0.7.7"
timing: timing:
dependency: transitive dependency: transitive
description: description:
@@ -833,10 +833,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.4" version: "2.2.0"
vm_service: vm_service:
dependency: transitive dependency: transitive
description: description:
@@ -910,5 +910,5 @@ packages:
source: hosted source: hosted
version: "3.1.3" version: "3.1.3"
sdks: sdks:
dart: ">=3.7.0 <4.0.0" dart: ">=3.9.0 <4.0.0"
flutter: ">=3.29.0" flutter: ">=3.35.0"

View File

@@ -11,8 +11,8 @@ dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
cupertino_icons: ^1.0.8 cupertino_icons: ^1.0.8
shared_preferences: ^2.3.0 shared_preferences: ^2.5.5
intl: ^0.19.0 intl: ^0.20.2
provider: ^6.1.1 provider: ^6.1.1
syncfusion_flutter_charts: ^30.1.41 syncfusion_flutter_charts: ^30.1.41
dio: ^5.7.0 dio: ^5.7.0