onDataSourceSuccess method
Called when the databroker returns a successful result
ChartModel overrides WidgetModel's onDataSourceSuccess to populate the series data from the datasource and to populate the label data from the datasource data.
Implementation
@override
Future<bool> onDataSourceSuccess(IDataSource source, Data? list) async {
try {
//here if the data strategy is category, we must fold all of the lists together and create a dummy key value map of every unique value, in order
uniqueValues.clear();
barDataList.clear();
for (var serie in series) {
serie.xValues.clear();
// build the datapoints for the series, passing in the chart type, index, and data
if (source.id == serie.datasource) {
serie.xValues.clear();
serie.plotPoints(list, uniqueValues);
}
if (serie.type == 'stacked' || serie.type == 'grouped') {
uniqueValues.add(serie.name);
}
uniqueValues.addAll(serie.xValues);
// add the built x values to a unique list to map to indeces
barDataList.addAll(serie.barDataPoint);
notifyListeners('list', null);
}
} catch (e) {
Log().debug('Series onDataSourceSuccess() error');
// DialogService().show(type: DialogType.error, title: phrase.error, description: e.message);
}
return true;
}