PieChartSectionData constructor

PieChartSectionData({
  1. double? value,
  2. Color? color,
  3. Gradient? gradient,
  4. double? radius,
  5. bool? showTitle,
  6. TextStyle? titleStyle,
  7. String? title,
  8. BorderSide? borderSide,
  9. Widget? badgeWidget,
  10. double? titlePositionPercentageOffset,
  11. double? badgePositionPercentageOffset,
})

PieChart draws section from right side of the circle (0 degrees), each section have a value that determines how much it should occupy, this is depends on sum of all sections, each section should occupy (value / sumValues) * 360 degrees.

It draws this section with filled color, and radius.

If showTitle is true, it draws a title at the middle of section, you can set the text using title, and set the style using titleStyle, by default it draws texts at the middle of section, but you can change the titlePositionPercentageOffset to have your desire design, it should be between 0.0 to 1.0, 0.0 means near the center, 1.0 means near the outside of the PieChart.

If badgeWidget is not null, it draws a widget at the middle of section, by default it draws the widget at the middle of section, but you can change the badgePositionPercentageOffset to have your desire design, the value works the same way as titlePositionPercentageOffset.

Implementation

PieChartSectionData({
  double? value,
  Color? color,
  this.gradient,
  double? radius,
  bool? showTitle,
  this.titleStyle,
  String? title,
  BorderSide? borderSide,
  this.badgeWidget,
  double? titlePositionPercentageOffset,
  double? badgePositionPercentageOffset,
})  : value = value ?? 10,
      color = color ?? Colors.cyan,
      radius = radius ?? 40,
      showTitle = showTitle ?? true,
      title = title ?? (value == null ? '' : value.toString()),
      borderSide = borderSide ?? const BorderSide(width: 0),
      titlePositionPercentageOffset = titlePositionPercentageOffset ?? 0.5,
      badgePositionPercentageOffset = badgePositionPercentageOffset ?? 0.5;