decodeSelectNearest<D> static method

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

Decodes the object from a Map-like dynamic structure. This expects the JSON format to be of the following structure:

{
  "eventTrigger": <SelectionTrigger>,
  "maximumDomainDistancePx": <int>,
  "selectAcrossAllDrawAreaComponents": <bool>,
  "selectClosestSeries": <bool>,
  "selectionMode": <SelectionMode>,
  "selectionModelType": <SelectionModelType>
}

See also:

Implementation

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

  if (map is charts.SelectNearest<D>) {
    result = map;
  } else if (map != null) {
    assert(SchemaValidator.validate(
      schemaId: '$_baseSchemaUrl/select_nearest',
      value: map,
      validate: validate,
    ));
    result = charts.SelectNearest<D>(
      eventTrigger: decodeSelectionTrigger(
            map['eventTrigger'],
            validate: false,
          ) ??
          common.SelectionTrigger.tap,
      maximumDomainDistancePx: JsonClass.parseInt(
        map['maximumDomainDistancePx'],
      ),
      selectAcrossAllDrawAreaComponents: JsonClass.parseBool(
        map['selectAcrossAllDrawAreaComponents'],
      ),
      selectClosestSeries: JsonClass.parseBool(
        map['selectClosestSeries'],
        whenNull: true,
      ),
      selectionMode: decodeSelectionMode(
            map['selectionMode'],
            validate: false,
          ) ??
          common.SelectionMode.expandToDomain,
      selectionModelType: decodeSelectionModelType(
            map['selectionModelType'],
            validate: false,
          ) ??
          common.SelectionModelType.info,
    );
  }

  return result;
}