onDataSourceSuccess method

Future<bool> onDataSourceSuccess(
  1. IDataSource source,
  2. Data? list
)
override

Called when the databroker returns a successful result

ChartModel overrides WidgetModel's onDataSourceSuccess to populate the series data with the databroker's data

Implementation

Future<bool> onDataSourceSuccess(IDataSource source, Data? list) async
{
  try
  {
      this.series.forEach((series) {
        if (series.datasource == source.id) {
          series.dataPoint.clear();
          if (list != null)
            list.forEach((p) {
              ChartDataPoint point = series.point(p);
              if ((point.x != null) && (point.y != null))
                series.dataPoint.add(point);
            });
          series.data = list;
        }
      });
    notifyListeners('list', null);
  }
  catch(e)
  {
    Log().debug('Series onDataSourceSuccess() error');
    // DialogService().show(type: DialogType.error, title: phrase.error, description: e.message);
  }
  return true;
}