更新样式
This commit is contained in:
@@ -29,41 +29,112 @@ class SleepRadarChart extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
// Widget _buildRadarChart() {
|
||||
// return AspectRatio(
|
||||
// aspectRatio: 1.3,
|
||||
// child: RadarChart(
|
||||
// RadarChartData(
|
||||
// dataSets: [
|
||||
// // 今日数据
|
||||
// RadarDataSet(
|
||||
// dataEntries: data
|
||||
// .map((e) => RadarEntry(value: (e['t'] as num).toDouble()))
|
||||
// .toList(),
|
||||
// borderColor: stringToColor("#00C1AA"),
|
||||
// borderWidth: 2,
|
||||
// fillColor: Colors.transparent,
|
||||
// entryRadius: 0,
|
||||
// ),
|
||||
// // 昨日数据
|
||||
// RadarDataSet(
|
||||
// dataEntries: data
|
||||
// .map((e) => RadarEntry(value: (e['y'] as num).toDouble()))
|
||||
// .toList(),
|
||||
// borderColor: stringToColor("#FFD251"),
|
||||
// borderWidth: 2,
|
||||
// fillColor: Colors.transparent,
|
||||
// entryRadius: 0,
|
||||
// ),
|
||||
// ],
|
||||
// radarBackgroundColor: stringToColor("#343844").withOpacity(0.6),
|
||||
// radarBorderData: BorderSide(
|
||||
// color: themeController.currentColor.sc4, width: 0.5.rpx),
|
||||
// radarShape: RadarShape.polygon,
|
||||
// titlePositionPercentageOffset: 0.2,
|
||||
// titleTextStyle: TextStyle(
|
||||
// fontSize: AppConstants().normal_text_fontSize,
|
||||
// color: themeController.currentColor.sc3),
|
||||
// getTitle: (index, angle) {
|
||||
// return RadarChartTitle(text: data[index]['name'] ?? '未知'.tr);
|
||||
// },
|
||||
// tickCount: 5,
|
||||
// ticksTextStyle:
|
||||
// const TextStyle(color: Colors.transparent, fontSize: 10),
|
||||
// gridBorderData: BorderSide(color: Colors.transparent, width: 1),
|
||||
// tickBorderData: BorderSide(
|
||||
// color: themeController.currentColor.sc4, width: 0.5.rpx),
|
||||
// ),
|
||||
// swapAnimationDuration: const Duration(milliseconds: 400),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
|
||||
Widget _buildRadarChart() {
|
||||
// 判断 t 是否全为 0(今日)
|
||||
final bool isTodayAllZero =
|
||||
data.every((e) => (e['t'] as num).toDouble() == 0);
|
||||
|
||||
// 判断 y 是否全为 0(昨日)
|
||||
final bool isYesterdayAllZero =
|
||||
data.every((e) => (e['y'] as num).toDouble() == 0);
|
||||
|
||||
// 构建 dataSets
|
||||
final List<RadarDataSet> dataSets = [];
|
||||
|
||||
// 今日数据(非全 0 才加入)
|
||||
if (!isTodayAllZero) {
|
||||
dataSets.add(
|
||||
RadarDataSet(
|
||||
dataEntries: data
|
||||
.map((e) => RadarEntry(value: (e['t'] as num).toDouble()))
|
||||
.toList(),
|
||||
borderColor: stringToColor("#00C1AA"),
|
||||
borderWidth: 2,
|
||||
fillColor: Colors.transparent,
|
||||
entryRadius: 0,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 昨日数据(非全 0 才加入)
|
||||
if (!isYesterdayAllZero) {
|
||||
dataSets.add(
|
||||
RadarDataSet(
|
||||
dataEntries: data
|
||||
.map((e) => RadarEntry(value: (e['y'] as num).toDouble()))
|
||||
.toList(),
|
||||
borderColor: stringToColor("#FFD251"),
|
||||
borderWidth: 2,
|
||||
fillColor: Colors.transparent,
|
||||
entryRadius: 0,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return AspectRatio(
|
||||
aspectRatio: 1.3,
|
||||
child: RadarChart(
|
||||
RadarChartData(
|
||||
dataSets: [
|
||||
// 今日数据
|
||||
RadarDataSet(
|
||||
dataEntries: data
|
||||
.map((e) => RadarEntry(value: (e['t'] as num).toDouble()))
|
||||
.toList(),
|
||||
borderColor: stringToColor("#00C1AA"),
|
||||
borderWidth: 2,
|
||||
fillColor: Colors.transparent,
|
||||
entryRadius: 0,
|
||||
),
|
||||
// 昨日数据
|
||||
RadarDataSet(
|
||||
dataEntries: data
|
||||
.map((e) => RadarEntry(value: (e['y'] as num).toDouble()))
|
||||
.toList(),
|
||||
borderColor: stringToColor("#FFD251"),
|
||||
borderWidth: 2,
|
||||
fillColor: Colors.transparent,
|
||||
entryRadius: 0,
|
||||
),
|
||||
],
|
||||
dataSets: dataSets,
|
||||
radarBackgroundColor: stringToColor("#343844").withOpacity(0.6),
|
||||
radarBorderData: BorderSide(
|
||||
color: themeController.currentColor.sc4, width: 0.5.rpx),
|
||||
radarShape: RadarShape.polygon,
|
||||
titlePositionPercentageOffset: 0.2,
|
||||
titleTextStyle: TextStyle(
|
||||
fontSize: AppConstants().normal_text_fontSize,
|
||||
color: themeController.currentColor.sc3),
|
||||
fontSize: AppConstants().normal_text_fontSize,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
getTitle: (index, angle) {
|
||||
return RadarChartTitle(text: data[index]['name'] ?? '未知'.tr);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user