I have this pie chart created by Flutter pie_chart plugin.
return SizedBox(
height: 150.0,
child: Stack(
children: [
PieChart(
baseChartColor: AmbarColors.greyNoEvents,
totalValue: hoursSpent,
dataMap: dataMap,
// degreeOptions: const DegreeOptions(totalDegrees: 360, initialAngle: 0),
animationDuration: Duration(milliseconds: 2000),
chartLegendSpacing: 22,
chartRadius: MediaQuery.of(context).size.width / 3.2,
colorList: const [AmbarColors.backgroundGreen],
initialAngleInDegree: 0,
chartType: ChartType.ring,
ringStrokeWidth: 17,
centerText: '$percent%',
centerTextStyle: const TextStyle(
fontWeight: FontWeight.bold,
fontFamily: Fonts.satoshi,
fontSize: 30),
legendOptions: const LegendOptions(
showLegends: false,
),
chartValuesOptions: const ChartValuesOptions(
showChartValueBackground: false,
showChartValues: false,
showChartValuesInPercentage: true,
),
gradientList: gradientList,
// gradientList: ---To add gradient colors---
// emptyColorGradient: ---Empty Color gradient---
)
],
));
}
The problem is when I put the chart into a scrolling area. This is the result:
The chart rotates every time I move the mouse and I don't understand why.
How can I fix this problem?
Finally I have put SingleChildScrollView with never scrollable physics. This must be a bug in the plugin.
return SizedBox(
height: 180.0,
child: Stack(
children: [
SingleChildScrollView( //<!------in this point
physics: const NeverScrollableScrollPhysics(),
child: PieChart(
baseChartColor: Colors.greyNoEvents,
totalValue: hoursSpent,
dataMap: dataMap,
animationDuration: Duration(milliseconds: 2000),
chartLegendSpacing: 22,
chartRadius: MediaQuery.of(context).size.width / 3.2,
colorList: const [Colors.backgroundGreen],
initialAngleInDegree: 0,
chartType: ChartType.ring,
ringStrokeWidth: 17,
centerText: '$subsPercent%',
centerTextStyle: const TextStyle(
fontWeight: FontWeight.bold,
fontFamily: Fonts.satoshi,
fontSize: 30),
legendOptions: const LegendOptions(
showLegends: false,
),
chartValuesOptions: const ChartValuesOptions(
showChartValueBackground: false,
showChartValues: false,
showChartValuesInPercentage: true,
),
gradientList: gradientList,
// gradientList: ---To add gradient colors---
// emptyColorGradient: ---Empty Color gradient---
),
)
],
),
);
}