validate method

void validate()

Implementation

void validate() {
  if (!(dataRows.length == dataRowsLegends.length)) {
    throw StateError('The number of legend labels provided in parameter "dataRowsLegends", '
        'does not equal the number of data rows provided in parameter "dataRows":\n'
        'Detail reason: Row legend labels must be provided in parameter "dataRowsLegends", '
        'and their number must be the same as number of data rows. '
        'However, in your data definition, that is not the case:\n'
        '   [number of dataRows: ${dataRows.length}] != [number of dataRowsLegends: ${dataRowsLegends.length}].\n'
        'To fix this: provide ${dataRows.length} "dataRowsLegends".');
  }
  if (!(dataRows.length == dataRowsColors.length)) {
    throw StateError('The number of legend colors provided in parameter "dataRowsColors", '
        'does not equal the number of data rows provided in parameter "dataRows":\n'
        'Detail reason: If not provided in "dataRowsColors", legend colors are generated. '
        'If the parameter "dataRowsColors" is provided, '
        'the number of colors must be the same as number of data rows. '
        'However, in your data definition, that is not the case:\n'
        '   [number of dataRows: ${dataRows.length}] != [number of dataRowsColors: ${dataRowsColors.length}].\n'
        'To fix this: provide ${dataRows.length} "dataRowsColors".');
  }

  for (List<double> dataRow in dataRows) {
    if (!(dataRow.length == xUserLabels.length)) {
      throw StateError('If xUserLabels are defined, their '
          'length must be the same as length of each dataRow'
          ' [dataRow length: ${dataRow.length}] '
          '!= [xUserLabels length: ${xUserLabels.length}]. ');
    }
  }
  // Check explicit log10 used in options. This test does not cover user's explicitly declared transforms.
  if (log10 == chartOptions.dataContainerOptions.yTransform) {
    if (!(dataYMin > 0.0)) {
      throw StateError('Using logarithmic Y scale requires only positive Y data');
    }
  }
}