initializeCharts function

dynamic initializeCharts()

Implementation

initializeCharts() {
  formItemUIBuilders['chart'] = (FormItemBuildEvent event) {
    FormItemDelegate formItem = event.formItem;

    String type = formItem.property('type');

    Widget? widget;

    List<Map<String, dynamic>> data = [];
    var property = formItem.property('data');
    if (property is List) {
      for (var value in property) {
        data.add(value as Map<String, dynamic>);
      }
    }
    switch (type) {
      case 'pie_chart':
        widget = PieChartContainer(data: data);
        break;
      case 'circle_percent_indicator':
        widget = CircularPercentIndicator(
          radius: (formItem.property('radius') as num).toDouble(),
          lineWidth: (formItem.property('line_width') as num).toDouble(),
          percent: (formItem.property('percent') as num).toDouble(),
          center: Text(formItem.property('label')),
          progressColor: fromHex(formItem.property('progress_color')),
        );
        break;
      case 'bar_chart':
        widget = const SizedBox.shrink();
        break;
      case 'line_chart':
        widget = const SizedBox.shrink();
        break;
      case 'scatter_plot':
        widget = const SizedBox.shrink();
        break;
      case 'time_series':
        widget = const SizedBox.shrink();
        break;
      case 'ordinal_combo':
        widget = const SizedBox.shrink();
        break;
      case 'numeric_combo':
        widget = const SizedBox.shrink();
        break;
    }

    if (widget != null) {
      widget = SizedBox(
        height: 300,
        width: 300,
        child: widget,
      );
    } else {
      widget = const SizedBox.shrink();
    }

    return widget;
  };
}