93 lines
2.3 KiB
Dart
93 lines
2.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:fl_chart/fl_chart.dart';
|
|
import '../tokens/unionflow_colors.dart';
|
|
|
|
/// Graphique circulaire UnionFlow - Pour afficher des répartitions
|
|
class UnionPieChart extends StatelessWidget {
|
|
final List<PieChartSectionData> sections;
|
|
final String title;
|
|
final String? subtitle;
|
|
final double? centerSpaceRadius;
|
|
|
|
const UnionPieChart({
|
|
super.key,
|
|
required this.sections,
|
|
required this.title,
|
|
this.subtitle,
|
|
this.centerSpaceRadius,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
padding: const EdgeInsets.all(20),
|
|
decoration: BoxDecoration(
|
|
color: UnionFlowColors.surface,
|
|
borderRadius: BorderRadius.circular(16),
|
|
boxShadow: UnionFlowColors.softShadow,
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
// Header
|
|
Text(
|
|
title,
|
|
style: const TextStyle(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w600,
|
|
color: UnionFlowColors.textPrimary,
|
|
),
|
|
),
|
|
if (subtitle != null) ...[
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
subtitle!,
|
|
style: const TextStyle(
|
|
fontSize: 11,
|
|
color: UnionFlowColors.textSecondary,
|
|
),
|
|
),
|
|
],
|
|
const SizedBox(height: 20),
|
|
|
|
// Chart
|
|
SizedBox(
|
|
height: 180,
|
|
child: PieChart(
|
|
PieChartData(
|
|
sectionsSpace: 2,
|
|
centerSpaceRadius: centerSpaceRadius ?? 50,
|
|
sections: sections,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Helper pour créer des sections de pie chart
|
|
class UnionPieChartSection {
|
|
static PieChartSectionData create({
|
|
required double value,
|
|
required Color color,
|
|
required String title,
|
|
double radius = 50,
|
|
bool showTitle = true,
|
|
}) {
|
|
return PieChartSectionData(
|
|
color: color,
|
|
value: value,
|
|
title: showTitle ? title : '',
|
|
radius: radius,
|
|
titleStyle: const TextStyle(
|
|
fontSize: 11,
|
|
fontWeight: FontWeight.w600,
|
|
color: Colors.white,
|
|
),
|
|
badgeWidget: null,
|
|
);
|
|
}
|
|
}
|