KinHeatmap.flat constructor

KinHeatmap.flat({
  1. Key? key,
  2. required List<double> values,
  3. required int columns,
  4. List<String>? columnLabels,
  5. List<String>? rowLabels,
  6. double cellSize = 14,
  7. double cellGap = 3,
  8. double cellRadius = 3,
  9. KinHeatmapColorScale? colorScale,
  10. void onCellTap(
    1. int row,
    2. int col,
    3. KinHeatmapCell cell
    )?,
})

Convenience factory: flat list of values mapped into a grid with columns per row.

Implementation

factory KinHeatmap.flat({
  Key? key,
  required List<double> values,
  required int columns,
  List<String>? columnLabels,
  List<String>? rowLabels,
  double cellSize = 14,
  double cellGap = 3,
  double cellRadius = 3,
  KinHeatmapColorScale? colorScale,
  void Function(int row, int col, KinHeatmapCell cell)? onCellTap,
}) {
  final rows = <List<KinHeatmapCell>>[];
  for (int i = 0; i < values.length; i += columns) {
    final end = (i + columns).clamp(0, values.length);
    rows.add([
      for (int j = i; j < end; j++) KinHeatmapCell(value: values[j]),
    ]);
  }
  return KinHeatmap(
    key: key,
    data: rows,
    columnLabels: columnLabels,
    rowLabels: rowLabels,
    cellSize: cellSize,
    cellGap: cellGap,
    cellRadius: cellRadius,
    colorScale: colorScale,
    onCellTap: onCellTap,
  );
}