From 6ac4141590ef913e0f56c41eeea900820b966bf6 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 16 Feb 2020 15:02:19 +0200 Subject: [PATCH] Charts --- lib/ui/reports/reports_screen.dart | 53 ++++++++++++++++++------------ 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/lib/ui/reports/reports_screen.dart b/lib/ui/reports/reports_screen.dart index fd3cc17f4..2e08135dc 100644 --- a/lib/ui/reports/reports_screen.dart +++ b/lib/ui/reports/reports_screen.dart @@ -382,32 +382,43 @@ class ReportCharts extends StatelessWidget { ), labelStyle: charts.TextStyleSpec(fontSize: 10, color: color))); - return FormCard( - child: SizedBox( - height: 200, - child: charts.BarChart( + Widget child; + switch (getReportColumnType(reportsUIState.group)) { + case ReportColumnType.string: + case ReportColumnType.bool: + child = charts.BarChart( [ - new charts.Series( - id: 'chart', - colorFn: (dynamic _, __) => - charts.MaterialPalette.blue.shadeDefault, - domainFn: (dynamic item, _) => item['name'], - measureFn: (dynamic item, _) => item['value'], - data: viewModel.reportTotals.keys - .map((key) => { - 'name': key, - 'value': viewModel.reportTotals[key] - [reportsUIState.chart] - }) - .toList(), - ) + charts.Series( + id: 'chart', + colorFn: (dynamic _, __) => + charts.MaterialPalette.blue.shadeDefault, + domainFn: (dynamic item, _) => item['name'], + measureFn: (dynamic item, _) => item['value'], + data: viewModel.reportTotals.keys + .map((key) => { + 'name': key, + 'value': viewModel.reportTotals[key] + [reportsUIState.chart] + }) + .toList()) ], animate: true, primaryMeasureAxis: numericAxis, domainAxis: axis, - ), - ), - ); + ); + break; + case ReportColumnType.dateTime: + case ReportColumnType.number: + } + + return child == null + ? SizedBox() + : FormCard( + child: SizedBox( + height: 200, + child: child, + ), + ); } }