FunnelChartConfig.fromJson constructor

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

Implementation

factory FunnelChartConfig.fromJson(Map<String, dynamic> json) {
  final items = ChartSeriesJson.firstSeriesData(
    json['series'],
  ).map(FunnelItem.fromJson).toList();

  final modeStr = json['funnelMode']?.toString().toLowerCase() ?? 'funnel';
  return FunnelChartConfig(
    items: items,
    funnelMode: modeStr == 'pyramid' ? FunnelMode.pyramid : FunnelMode.funnel,
    showLabels: JsonValue.boolOrNull(json['showLabels']) ?? true,
    showValues: JsonValue.boolOrNull(json['showValues']) ?? true,
    showPercentage: JsonValue.boolOrNull(json['showPercentage']) ?? false,
    showConversionRate:
        JsonValue.boolOrNull(json['showConversionRate']) ?? false,
    neckWidthFraction:
        JsonValue.doubleOrNull(json['neckWidthFraction']) ?? 0.18,
    gapFraction: JsonValue.doubleOrNull(json['gapFraction']) ?? 0.015,
    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,
  );
}