This commit is contained in:
Hillel Coren 2020-02-16 15:02:19 +02:00
parent 31b355fc8f
commit 6ac4141590
1 changed files with 32 additions and 21 deletions

View File

@ -382,32 +382,43 @@ class ReportCharts extends StatelessWidget {
), ),
labelStyle: charts.TextStyleSpec(fontSize: 10, color: color))); labelStyle: charts.TextStyleSpec(fontSize: 10, color: color)));
return FormCard( Widget child;
child: SizedBox( switch (getReportColumnType(reportsUIState.group)) {
height: 200, case ReportColumnType.string:
child: charts.BarChart( case ReportColumnType.bool:
child = charts.BarChart(
[ [
new charts.Series<dynamic, String>( charts.Series<dynamic, String>(
id: 'chart', id: 'chart',
colorFn: (dynamic _, __) => colorFn: (dynamic _, __) =>
charts.MaterialPalette.blue.shadeDefault, charts.MaterialPalette.blue.shadeDefault,
domainFn: (dynamic item, _) => item['name'], domainFn: (dynamic item, _) => item['name'],
measureFn: (dynamic item, _) => item['value'], measureFn: (dynamic item, _) => item['value'],
data: viewModel.reportTotals.keys data: viewModel.reportTotals.keys
.map((key) => { .map((key) => {
'name': key, 'name': key,
'value': viewModel.reportTotals[key] 'value': viewModel.reportTotals[key]
[reportsUIState.chart] [reportsUIState.chart]
}) })
.toList(), .toList())
)
], ],
animate: true, animate: true,
primaryMeasureAxis: numericAxis, primaryMeasureAxis: numericAxis,
domainAxis: axis, domainAxis: axis,
), );
), break;
); case ReportColumnType.dateTime:
case ReportColumnType.number:
}
return child == null
? SizedBox()
: FormCard(
child: SizedBox(
height: 200,
child: child,
),
);
} }
} }