CustomChartConfig.fromJson constructor

CustomChartConfig.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory CustomChartConfig.fromJson(Map<String, dynamic> json) {
  final subType = json['subType']?.toString();

  // If there is a registered sub-type factory, delegate to it.
  if (subType != null) {
    final reg = CustomSubTypeRegistry.findBySubType(subType);
    if (reg != null) {
      return reg(json) as CustomChartConfig;
    }
  }

  return CustomChartConfig(
    rawData: (json['data'] as Map<String, dynamic>?) ?? {},
    subType: subType,
    title: json['title'] != null ? TitlesData.fromJson(json['title']) : null,
    tooltip: json['tooltip'] != null
        ? ChartTooltip.fromJson(json['tooltip'])
        : null,
    legend: json['legend'] != null
        ? ChartLegend.fromJson(json['legend'])
        : null,
    toolbox: json['toolbox'] != null
        ? ChartToolbox.fromJson(json['toolbox'])
        : null,
    grid: json['grid'] != null ? GridData.fromJson(json['grid']) : null,
  );
}