decodeBarRendererConfig<D> static method

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

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

{
  "barGroupInnerPaddingPx": <int>,
  "barRendererDecorator": <BarRendererDecorator>,
  "cornerStrategy": <CornerStrategy>,
  "customRendererId": <String>,
  "fillPattern": <FillPatternType>,
  "groupingType": <BarGroupingType>,
  "layoutPaintOrder": <int>,
  "maxBarWidthPx": <int>,
  "minBarLengthPx": <int>,
  "stackedBarPaddingPx": <int>,
  "strokeWidthPx": <double>,
  "symbolRenderer": <SymbolRenderer>,
  "weightPattern": <List<int>>
}

Type: "target_line"

{
  "barGroupInnerPaddingPx": <int>,
  "customRendererId": <String>,
  "dashPattern": <List<int>>,
  "groupingType": <BarGroupingType>,
  "layoutPaintOrder": <int>,
  "minBarLengthPx": <int>,
  "overDrawOuterPx": <int>,
  "overDrawPx": <int>,
  "roundEndCaps": <double>,
  "strokeWidthPx": <double>,
  "symbolRenderer": <SymbolRenderer>,
  "type": "target_line",
  "weightPattern": <List<int>>
}

See also:

Implementation

static common.BaseBarRendererConfig<D>? decodeBarRendererConfig<D>(
  dynamic map, {
  bool validate = true,
}) {
  common.BaseBarRendererConfig<D>? result;

  if (map != null) {
    assert(SchemaValidator.validate(
      schemaId: '$_baseSchemaUrl/bar_renderer_config',
      value: map,
      validate: validate,
    ));
    final type = map['type'];

    switch (type) {
      case 'bar_target_line':
      case 'target_line':
        result = decodeBarTargetLineRendererConfig<D>(
          map,
          validate: false,
        );
        break;

      default:
        result = charts.BarRendererConfig<D>(
          barGroupInnerPaddingPx: JsonClass.parseInt(
                map['barGroupInnerPaddingPx'],
              ) ??
              2,
          barRendererDecorator: map['barRendererDecorator'],
          cornerStrategy: decodeCornerStrategy(
            map['cornerStrategy'],
            validate: false,
          ),
          customRendererId: map['customRendererId']?.toString(),
          fillPattern: decodeFillPatternType(
            map['fillPattern'],
            validate: false,
          ),
          groupingType: decodeBarGroupingType(
            map['groupingType'],
            validate: false,
          ),
          layoutPaintOrder: JsonClass.parseInt(map['layoutPaintOrder']) ??
              charts.LayoutViewPaintOrder.bar,
          maxBarWidthPx: JsonClass.parseInt(map['maxBarWidthPx']),
          minBarLengthPx: JsonClass.parseInt(map['minBarLengthPx']) ?? 0,
          stackedBarPaddingPx: JsonClass.parseInt(
                map['stackedBarPaddingPx'],
              ) ??
              1,
          strokeWidthPx: JsonClass.parseDouble(map['strokeWidthPx']) ?? 0.0,
          symbolRenderer: decodeSymbolRenderer(
            map['symbolRenderer'],
            validate: false,
          ),
          weightPattern: map['weightPattern'] == null
              ? null
              : ((map['weightPattern'] as List)
                  .map((e) => JsonClass.parseInt(e)!)).toList(),
        );
    }
  }

  return result;
}