ChartRadar.withChartData constructor

ChartRadar.withChartData(
  1. List data, {
  2. int desiredCount = 4,
  3. bool useSides = true,
  4. double? height,
  5. bool showLegend = true,
  6. Color outlineColor = Colors.grey,
  7. Color axisColor = Colors.grey,
  8. TextStyle tickStyle = const TextStyle(color: Colors.grey, fontSize: 12),
  9. TextStyle labelStyle = const TextStyle(color: Color(0xff707f89), fontSize: 14),
  10. ValueChanged? onSelectionChanged,
})

Implementation

factory ChartRadar.withChartData(List data,
    {int desiredCount = 4,
    bool useSides = true,
    double? height,
    bool showLegend = true,
    Color outlineColor = Colors.grey,
    Color axisColor = Colors.grey,
    TextStyle tickStyle = const TextStyle(color: Colors.grey, fontSize: 12),
    TextStyle labelStyle =
        const TextStyle(color: Color(0xff707f89), fontSize: 14),
    ValueChanged? onSelectionChanged}) {
  var radarData =
      data.map<ChartLineData>((e) => ChartLineData.fromJson(e)).toList();
  var seriesData = _makeData<String>(radarData, 0);
  var maxV = radarData.reduce((a, b) => a.y! > b.y! ? a : b);

  List<int> ticks = [];

  int t = (maxV.y! / desiredCount).ceil().toInt();
  ticks =
      Iterable<int>.generate(desiredCount).map((e) => t * (e + 1)).toList();
  return ChartRadar(
    lineData: seriesData,
    ticks: ticks,
    reverseAxis: false,
    height: height,
    showLegend: showLegend,
    outlineColor: outlineColor,
    axisColor: axisColor,
    ticksTextStyle: tickStyle,
    featuresTextStyle: labelStyle,
    sides: useSides ? seriesData.first.data.length : 0,
    onSelectionChanged: onSelectionChanged,
  );
}