syncfusion / flutter-widgets

Syncfusion Flutter widgets libraries include high quality UI widgets and file-format packages to help you create rich, high-quality applications for iOS, Android, and web from a single code base.
1.56k stars 758 forks source link

Exception using RadialBarSeries / SfCircularChart #2084

Open Abhijit-Revamp opened 3 days ago

Abhijit-Revamp commented 3 days ago

Bug description

While adding RadialBarSeries, getting an exception in the following function

  List<LegendItem>? buildLegendItems(int index) {
    final num sumOfY = circularYValues

Steps to reproduce

  1. Add a RadialBarSeries
  2. No customisation - very basic
  3. ensure dataSource has more than 1 item (this is just to ensure something gets rendered)
  4. select Chrome - web as target debugging platform
  5. start debugging

    Exception <<

Code sample

Code sample ```dart child: SfCircularChart( series: [ // Render pie chart RadialBarSeries( dataSource: viewModel.db01GroupedSumCount, xValueMapper: (data, _) => data["typeID"], yValueMapper: (data, _) => data["count"], ) ], ), ```

Screenshots or Video

Screenshots / Video demonstration image

Stack Traces

Stack Traces ```dart [Add the Stack Traces here] ```

On which target platforms have you observed this bug?

Web, Web (Android browser), Web (iOS browser)

Flutter Doctor output

Doctor output ```console Flutter (Channel beta, 3.26.0-0.1.pre, on macOS 14.6.1 23G93 darwin-x64, locale en-IN) • Flutter version 3.26.0-0.1.pre on channel beta at /Volumes/Abhi-Data/FlutterDev/SDK/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision ee624bc4fd (9 days ago), 2024-09-10 17:41:06 -0500 • Engine revision 059e4e6d8f • Dart version 3.6.0 (build 3.6.0-216.1.beta) • DevTools version 2.39.0```
ThilipChandru commented 2 days ago

Hi @Abhijit-Revamp,

We have checked the mentioned issue and tried to replicate it in the SfCircularChart with version 27.1.48 by:

  1. Ensured in Windows, Web and Android platforms.
  2. Ensured the Radial series with the default legend and legend item builder.
  3. Ensured the legend toggling with animation.
  4. Ensured by adding data points dynamically to the radial bar series.

However, we were unable to reproduce it on our end. Please check the attached sample, and if you are still experiencing the issue, we request that you replicate it in the attached sample and provide us with more details regarding the specific scenario in which you are encountering this issue. This will help us to assist you more effectively.

Sample: gh_2084.zip

Regards, Thilip Chandru.

Abhijit-Revamp commented 1 day ago

@ThilipChandru Thanks for the update. I found the problem. My data (and in real life app) comes from external source like web services or database. In one of the case, the entire data for radial series was BLANK (no data received). That causes the EXCEPTION. Temporarily I have handled this in my code. However, can you make the slight change in the code (function buildLegendItems) to either

  1. check empty list before calling "reduce"
  2. replace "reduce" with "fold" : Fold takes initial value as 0 and ensures there is no exception

Thanks