decodeChartBehavior<D> static method

ChartBehavior<D>? decodeChartBehavior<D>(
  1. dynamic map, {
  2. bool validate = true,
})

Decodes a dynamic value to an appropriate charts.ChartBehavior. Which renderer is used is determined by the "type", and the schema is then specific to that type. The following types are supported:

Implementation

static charts.ChartBehavior<D>? decodeChartBehavior<D>(
  dynamic map, {
  bool validate = true,
}) {
  charts.ChartBehavior<D>? result;

  if (map is charts.ChartBehavior<D>) {
    result = map;
  } else if (map != null) {
    assert(SchemaValidator.validate(
      schemaId: '$_baseSchemaUrl/chart_behavior',
      value: map,
      validate: validate,
    ));

    final type = map['type'];

    switch (type) {
      case 'chart_title':
        result = decodeChartTitle<D>(
          map,
          validate: false,
        );
        break;

      case 'datum_legend':
        result = decodeDatumLegend<D>(
          map,
          validate: false,
        );
        break;

      case 'domain_highlighter':
        result = decodeDomainHighlighter<D>(
          map,
          validate: false,
        );
        break;

      case 'initial_hint_behavior':
        result = decodeInitialHintBehavior<D>(
          map,
          validate: false,
        );
        break;

      case 'initial_selection':
        result = decodeInitialSelection<D>(
          map,
          validate: false,
        );
        break;

      case 'line_point_highlighter':
        result = decodeLinePointHighlighter<D>(
          map,
          validate: false,
        );
        break;

      case 'pan_and_zoom_behavior':
        result = decodePanAndZoomBehavior<D>(
          map,
          validate: false,
        );
        break;

      case 'percent_injector':
        result = decodePercentInjector<D>(
          map,
          validate: false,
        );
        break;

      case 'range_annotation':
        result = decodeRangeAnnotation<D>(
          map,
          validate: false,
        );
        break;

      case 'select_nearest':
        result = decodeSelectNearest<D>(
          map,
          validate: false,
        );
        break;

      case 'series_legend':
        result = decodeSeriesLegend<D>(
          map,
          validate: false,
        );
        break;

      case 'slider':
        result = decodeSlider<D>(
          map,
          validate: false,
        );
        break;

      case 'sliding_viewport':
        result = decodeSlidingViewport<D>(
          map,
          validate: false,
        );
        break;

      default:
        throw Exception(
          '[ChartBehavior.type]: unknown type: [$type]',
        );
    }
  }

  return result;
}