setPieAngle method

dynamic setPieAngle()

计算各个扇形的起始角度

Implementation

setPieAngle() {
  if (chartBeans?.isEmpty ?? true) {
    return;
  }
  double total = getTotal(chartBeans!);
  double rate = 0;
  double startAngle = 0; // 扇形开始的角度 正上方
  for (var bean in chartBeans!) {
    rate = bean.value / total; //当前对象值所占比例
    bean.rate = rate;
    bean.startAngle = startAngle;
    bean.sweepAngle = rate * 2 * pi; //当前对象所占比例 对应的 角度
    startAngle += bean.sweepAngle!;
  }
}