reports page
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:syncfusion_flutter_charts/charts.dart';
|
||||
import 'package:syncfusion_flutter_charts/charts.dart' hide ChartPoint;
|
||||
|
||||
import 'package:pshared/models/payment/operation.dart';
|
||||
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
import 'package:pweb/models/chart_point.dart';
|
||||
|
||||
|
||||
class PayoutDistributionChart extends StatelessWidget {
|
||||
@@ -25,7 +26,7 @@ class PayoutDistributionChart extends StatelessWidget {
|
||||
|
||||
// 2) Build chart data
|
||||
final data = sums.entries
|
||||
.map((e) => _ChartData(e.key, e.value))
|
||||
.map((e) => ChartPoint<String>(e.key, e.value))
|
||||
.toList();
|
||||
|
||||
// 3) Build a simple horizontal legend
|
||||
@@ -42,7 +43,7 @@ class PayoutDistributionChart extends StatelessWidget {
|
||||
children: [
|
||||
Icon(Icons.circle, size: 10, color: palette[i % palette.length]),
|
||||
const SizedBox(width: 4),
|
||||
Text(data[i].label, style: Theme.of(context).textTheme.bodySmall),
|
||||
Text(data[i].key, style: Theme.of(context).textTheme.bodySmall),
|
||||
if (i < data.length - 1) const SizedBox(width: 12),
|
||||
],
|
||||
);
|
||||
@@ -62,10 +63,10 @@ class PayoutDistributionChart extends StatelessWidget {
|
||||
child: SfCircularChart(
|
||||
legend: Legend(isVisible: false),
|
||||
tooltipBehavior: TooltipBehavior(enable: true),
|
||||
series: <PieSeries<_ChartData, String>>[
|
||||
PieSeries<_ChartData, String>(
|
||||
series: <PieSeries<ChartPoint<String>, String>>[
|
||||
PieSeries<ChartPoint<String>, String>(
|
||||
dataSource: data,
|
||||
xValueMapper: (d, _) => d.label,
|
||||
xValueMapper: (d, _) => d.key,
|
||||
yValueMapper: (d, _) => d.value,
|
||||
dataLabelMapper: (d, _) =>
|
||||
'${(d.value / sums.values.fold(0, (a, b) => a + b) * 100).toStringAsFixed(1)}%',
|
||||
@@ -95,9 +96,3 @@ class PayoutDistributionChart extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ChartData {
|
||||
final String label;
|
||||
final double value;
|
||||
_ChartData(this.label, this.value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user