SeriesItem.fromMaps constructor

SeriesItem.fromMaps(
  1. List<Map<String, dynamic>> rows, {
  2. required String name,
  3. required Color color,
  4. String mapXKey = 'x',
  5. String mapYKey = 'y',
  6. String? mapLabelKey,
  7. double pointRadius = 5.0,
  8. bool connectPoints = false,
  9. double lineWidth = 2.0,
  10. bool showPoints = true,
})

Implementation

factory SeriesItem.fromMaps(
  List<Map<String, dynamic>> rows, {
  required String name,
  required Color color,
  String mapXKey = 'x',
  String mapYKey = 'y',
  String? mapLabelKey,
  double pointRadius = 5.0,
  bool connectPoints = false,
  double lineWidth = 2.0,
  bool showPoints = true,
}) {
  return SeriesItem(
    name: name,
    color: color,
    pointRadius: pointRadius,
    connectPoints: connectPoints,
    lineWidth: lineWidth,
    showPoints: showPoints,
    points: rows
        .where((r) => r[mapXKey] != null && r[mapYKey] != null)
        .map(
          (r) => SeriesPoint.fromMap(
            r,
            mapXKey: mapXKey,
            mapYKey: mapYKey,
            mapLabelKey: mapLabelKey,
          ),
        )
        .toList(),
  );
}