decodeRangeAnnotationAxisType static method

RangeAnnotationAxisType? decodeRangeAnnotationAxisType(
  1. dynamic map, {
  2. bool validate = false,
})

Expects the map to be either a charts.RangeAnnotationAxisType or a String containing one of the following values:

  • domain
  • measure

Implementation

static common.RangeAnnotationAxisType? decodeRangeAnnotationAxisType(
  dynamic map, {
  bool validate = false,
}) {
  common.RangeAnnotationAxisType? result;

  if (map is common.RangeAnnotationAxisType) {
    result = map;
  } else if (map != null) {
    assert(SchemaValidator.validate(
      schemaId: '$_baseSchemaUrl/range_annotation_axis_type',
      value: map,
      validate: validate,
    ));
    switch (map) {
      case 'domain':
        result = common.RangeAnnotationAxisType.domain;
        break;

      case 'measure':
        result = common.RangeAnnotationAxisType.measure;
        break;

      default:
        throw Exception(
          '[decodeRangeAnnotationAxisType]: unknown value: [$map]',
        );
    }
  }

  return result;
}