ChartRadar.withChartData constructor
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,
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,
);
}