Skip to content

[Feature Request]: PieChart with exploding sections #2091

@jay-k98

Description

@jay-k98

Description

Highlighting a section by "exploding" it (or in other words sliding it outwards from the center) with smooth animations could add to the UX and add a new level of design possibilities for PieCharts.

Example

Image
Image

Proposed Solution

class PieChartSectionData {
  // ...
  final double sectionOffset;
  // ...
}

class PieChartPainter {
  // ...
  void drawSections(...) {
      final section = data.sections[i];
      if (section.value == 0) {
        continue;
      }
      final sectionDegree = sectionsAngle[i];

      // Compute offset for "exploded" sections
      final sectionCenterAngle = tempAngle + (sectionDegree / 2);
      final sectionOffset = section.sectionOffset;
      final offsetDx =
          math.cos(Utils().radians(sectionCenterAngle)) * sectionOffset;
      final offsetDy =
          math.sin(Utils().radians(sectionCenterAngle)) * sectionOffset;
      final sectionCenter = center.translate(offsetDx, offsetDy);
      // ...
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions