pie_chart
pie_chart copied to clipboard
Is it possible to have the center text without a background?
As shown in this image here
I have a ring chart, I've hidden all the legends but showed the center text. No matter what I do, the white background of this center text won't go away. Here's my code:
PieChart(
emptyColor: Colors.transparent,
key: ValueKey(1),
dataMap: <String, double>{
"prc_1": 50,
"prc2": 50,
},
animationDuration:
Duration(milliseconds: 800),
chartRadius:
MediaQuery.of(context).size.width /
3.2 >
300
? 300
: MediaQuery.of(context)
.size
.width /
3.2,
colorList: <Color>[
Colors.blue,
Colors.white
],
initialAngleInDegree: 270,
chartType: ChartType.ring,
centerText: 'Can we\nhave this\nwithout the\nwhite\nbackground',
centerTextStyle: TextStyle(
fontFamily: 'Overpass'),
legendOptions: LegendOptions(
showLegends: false,
),
chartValuesOptions: ChartValuesOptions(
showChartValues: false,
),
ringStrokeWidth: 7.5),
You can set chart value color to transparent
Alternative solution By wrapping the pie inside a stack with a center alignment you can draw anything inside your pie chart