stackedData method

List<Map<String, dynamic>> stackedData({
  1. int categories = 10,
  2. List<String>? categoryNames,
  3. List<String>? seriesNames,
  4. int seriesCount = 4,
  5. double minValue = 10,
  6. double maxValue = 50,
})

Generates stacked data.

Implementation

List<Map<String, dynamic>> stackedData({
  int categories = 10,
  List<String>? categoryNames,
  List<String>? seriesNames,
  int seriesCount = 4,
  double minValue = 10,
  double maxValue = 50,
}) {
  final series =
      seriesNames ?? List.generate(seriesCount, (i) => 'Series ${i + 1}');
  final categories_ =
      categoryNames ?? List.generate(categories, (i) => 'Cat ${i + 1}');

  return categories_.map((category) {
    final Map<String, dynamic> data = {'category': category};
    for (final s in series) {
      data[s] = _random.uniform(minValue, maxValue);
    }
    return data;
  }).toList();
}