58 lines
1.6 KiB
Dart
58 lines
1.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:vbvs_app/common/util/FitTool.dart';
|
|
|
|
class VerticalBarList extends StatelessWidget {
|
|
final List<Map<String, dynamic>> showLabel;
|
|
final double maxBarHeight;
|
|
final double barWidth;
|
|
|
|
const VerticalBarList({
|
|
super.key,
|
|
required this.showLabel,
|
|
this.maxBarHeight = 100.0, // 柱子的最大高度
|
|
this.barWidth = 20.0, // 每根柱子的宽度
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Row(
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: showLabel.map((item) {
|
|
final percent = item['percent'] ?? 0;
|
|
final color = item['color'] ?? Colors.grey;
|
|
final name = item['name'] ?? '';
|
|
|
|
final barHeight = maxBarHeight * (percent / 100.0);
|
|
|
|
return Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 8.rpx),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
// 柱子
|
|
Container(
|
|
width: barWidth.rpx,
|
|
height: barHeight.rpx,
|
|
decoration: BoxDecoration(
|
|
color: color,
|
|
borderRadius: BorderRadius.circular(4.rpx),
|
|
),
|
|
),
|
|
SizedBox(height: 8.rpx),
|
|
// 文字竖排
|
|
Text(
|
|
name,
|
|
style: TextStyle(
|
|
fontSize: 24.rpx,
|
|
color: Colors.white,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}).toList(),
|
|
);
|
|
}
|
|
}
|