I have question and request regarding the pie chart that I am using from syncfusion.
When I select multiple data as below, the % values show nicely in the center of each color.
But when I choose only 1 data, the % value does not appear in the center of the pie and it is slightly aligned near the bottom of the pie chart.
I tried to fix this problem by adding "ChartAlignment.center" to my code as below, but this issue is not being fixed. Can you help out to resolve this issue?
My version is:
syncfusion_flutter_charts: ^20.2.45
My code is:
SfCircularChart pieChart() {
List<String> keyList = _taskController.stringTypeMap.keys.toList();
return SfCircularChart(
palette: const [
Colors.pink,
Colors.blue,
Colors.green,
Colors.orange,
],
legend: Legend(
isVisible: true,
position: LegendPosition.right,
width: '40%',
),
margin: EdgeInsets.all(0),
tooltipBehavior: TooltipBehavior(
enable: true,
tooltipPosition: TooltipPosition.pointer,
),
series: <CircularSeries>[
PieSeries<String, String>(
legendIconType: LegendIconType.seriesType,
dataLabelMapper: (s, p) {
int totalStrings = 0;
_taskController.stringTypeMap.forEach((key, value) {
totalStrings = totalStrings + value;
});
double percentage =
(_taskController.stringTypeMap[s]! / totalStrings) * 100;
return '${percentage.toStringAsFixed(1)}%';
},
animationDuration: 2000,
enableTooltip: true,
dataSource: keyList,
xValueMapper: (String data, _) => data,
yValueMapper: (String data, _) => _taskController.stringTypeMap[data],
dataLabelSettings: const DataLabelSettings(
isVisible: true,
showZeroValue: false,
textStyle: TextStyle(color: Colors.white),
alignment: ChartAlignment.center,
),
),
],
);
}
Hi Yoon,
We are analyzing your query at our end and will update further details in one business day. We appreciate your patience until then.
Regards,
Sriram Kiran
Hi Yoon,
Greetings from Syncfusion.
We have checked your query at our end and we would like to let you know that the data labels in the pie chart series gets rendered at the center point of the pie data points’ slice and thus when there is only one point visible in the series, the data label gets rendered at the center of the pie slice which at the bottom part of the pie chart. This is the current default behavior.
However, we have considered your requirement as an improvement and logged a feature request for it in our feedback portal. We will prioritize the features and improvements of every release based on demand and priority. So, this improvement will be available in any of our upcoming releases. You can also track the status of the feature with the feedback below.
https://www.syncfusion.com/feedback/37564
Regards,
Sriram Kiran