When using the syncfusion_flutter_charts package in Flutter, if my data is 0 in the DoughnutSeries, what should I do?
I am developing an application in Flutter. When my incoming data is 0, the table does not appear at all as shown in the visual. How can I fix this? Can you help me?
The code is provided below:
List<GDPData> getChartData() {
final List<GDPData> chartData = [
GDPData(
'Yeni Talep',
newTicket,
Colors.blue.shade400,
"$newTicket ",
),
GDPData(
'İşlemde Bekleyen',
pendingTicket,
Colors.orange.shade400,
"$pendingTicket ",
),
GDPData(
'Tamamlanan',
completedTicket,
Colors.green.shade400,
"$completedTicket ",
),
];
return chartData;
}
SfCircularChart(
annotations: [
CircularChartAnnotation(
widget: Container(
padding: const EdgeInsets.all(10),
child: Text(
"$totalTicketCount",
style: const TextStyle(
fontSize: 20, fontWeight: FontWeight.bold),
)),
),
],
title: ChartTitle(text: 'Talep Durumları'),
legend: Legend(
isVisible: true,
overflowMode: LegendItemOverflowMode.wrap),
tooltipBehavior: _tooltipBehavior,
series: <CircularSeries>[
DoughnutSeries<GDPData, String>(
emptyPointSettings: EmptyPointSettings(
mode: EmptyPointMode.gap,
borderWidth: 1,
borderColor: Colors.black,
color: Colors.grey,
),
radius: '80%',
explode: true,
explodeOffset: '10%',
dataSource: _chartData,
strokeColor: Colors.black,
xValueMapper: (GDPData data, _) => data.status,
yValueMapper: (GDPData data, _) => data.count,
pointColorMapper: (GDPData data, _) => data.color,
dataLabelMapper: (GDPData data, _) => data.text,
dataLabelSettings: const DataLabelSettings(
isVisible: true,
),
enableTooltip: true,
)
],
)
Hi Omer,
We have checked your query, we suspect that you don't want the data labels in the doughnut chart when having the value as zero. To avoid this we suggest you to set the showZeroValue property in the DataLabelSettings to false then it will avoid rendering the data label for zero values. We have shared the code snippet below for your reference.
Code snippet:
SfCircularChart( series: <CircularSeries>[ DoughnutSeries<ChartData, String>( dataLabelSettings: const DataLabelSettings(isVisible: true, showZeroValue: false), ) ], ) |
Regards,
Yuvaraj.
The actual problem is that nothing appears on the graph when the value is zero. For example, if all values are zero, I want them to appear equally on the graph, and if only one value is zero, I want it to appear in a smaller form.
Hi Omer,
We have checked your query at our end and as we are not able to understand what you’re proposing as your requirement, we kindly request you to share us with more information on your requirement in detail along with screenshots/screen recordings so that it will help us assist you in a better way.
Regards,
Lokesh.
- 3 Replies
- 3 Participants
-
ÖF Ömer Faruk Duzcan
- Jun 2, 2023 01:52 PM UTC
- Jun 6, 2023 02:16 PM UTC