Skip to content

Conversation

@GeekTree0101
Copy link

Summary

This pull request adds a new callback onSegmentPressed to the PieChart widget, allowing developers to detect and respond when a specific pie segment is tapped.

Key Changes

  • Introduced onSegmentPressed(String key) callback in the PieChart constructor.
  • Wrapped chart area in a GestureDetector to capture tap positions.
  • Implemented angle calculation logic to map touch positions to corresponding pie segments.
  • Ensured compatibility with initialAngleInDegree and custom segment counts.

Use Case

This enables interactive chart behavior such as:

  • Highlighting selected segments
  • Showing tooltips or detailed views
  • Navigating based on chart input

Example

PieChart(
  dataMap: {
    'Food': 40,
    'Rent': 30,
    'Travel': 30,
  },
  onSegmentPressed: (key) {
    print('Tapped segment: $key');
  },
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant