Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding dataLabels will throw an exception when using ChartSeriesController to update the chart #1930

Closed
elethiame opened this issue Jun 17, 2024 · 3 comments
Labels
charts Charts component fixed Fixed and delivered update waiting for customer response Cannot make further progress until the customer responds.

Comments

@elethiame
Copy link

Bug description

Version: 26.1.35
We are using the ChartSeriesController to update the chart data.
Everything works fine until we set the builder in the DataLabelSettings, which throws an exception with a message: ‘RangeError (length): Invalid value: Valid value range is empty: 0’.

Steps to reproduce

  1. please use this demo: https://github.com/syncfusion/flutter-examples/blob/master/lib/samples/chart/cartesian_charts/real_time_charts/add_remove_data/add_remove_points.dart
  2. add data label settings in _getAddRemovePointSeries method:
    List<LineSeries<ChartSampleData, num>> _getAddRemovePointSeries() { return <LineSeries<ChartSampleData, num>>[ LineSeries<ChartSampleData, num>( onRendererCreated: (ChartSeriesController<ChartSampleData, num> controller) { _chartSeriesController = controller; }, dataLabelSettings: DataLabelSettings( isVisible: true, builder: (dynamic data, dynamic point, dynamic series, int pointIndex, int seriesIndex) { return Text( '${data.y}', style: TextStyle(color: Colors.white), ); }, ), animationDuration: 0, dataSource: chartData, xValueMapper: (ChartSampleData sales, _) => sales.x as num, yValueMapper: (ChartSampleData sales, _) => sales.y), ]; }
  3. tap the add button
  4. an error occurred when the data count exceeded 11

Code sample

Code sample
List<LineSeries<ChartSampleData, num>> _getAddRemovePointSeries() {
    return <LineSeries<ChartSampleData, num>>[
      LineSeries<ChartSampleData, num>(
          onRendererCreated:
              (ChartSeriesController<ChartSampleData, num> controller) {
            _chartSeriesController = controller;
          },
          dataLabelSettings: DataLabelSettings(
            isVisible: true,
            builder: (dynamic data, dynamic point, dynamic series,
                int pointIndex, int seriesIndex) {
              return Text(
                '${data.y}',
                style: TextStyle(color: Colors.white),
              );
            },
          ),
          animationDuration: 0,
          dataSource: chartData,
          xValueMapper: (ChartSampleData sales, _) => sales.x as num,
          yValueMapper: (ChartSampleData sales, _) => sales.y),
    ];
  }

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

20240618-061609.mp4

Stack Traces

Stack Traces
#8      RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:2688:59)
#9      PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:1097:15)
#10     RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:2688:14)
#11     RenderConstrainedLayoutBuilder.rebuildIfNecessary (package:flutter/src/widgets/layout_builder.dart:248:7)
#12     RenderChartElementLayoutBuilder.performLayout (package:syncfusion_flutter_charts/src/charts/common/element_widget.dart:128:5)
#13     RenderObject.layout (package:flutter/src/rendering/object.dart:2577:7)
#14     XyDataSeriesRenderer.performLayout (package:syncfusion_flutter_charts/src/charts/series/chart_series.dart:5824:13)
#15     RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:2416:7)
#16     PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1051:18)
#17     PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1064:15)
#18     RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:577:23)
#19     WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:1138:13)
#20     RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:443:5)
#21     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1392:15)
#22     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1313:9)
#23     SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1171:5)
#24     _invoke (dart:ui/hooks.dart:312:13)
#25     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:419:5)
#26     _drawFrame (dart:ui/hooks.dart:283:31)```

</details>


### On which target platforms have you observed this bug?

Android

### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
Doctor summary (to see all details, run flutter doctor -v):
[!] Flutter (Channel main, 3.22.0-13.0.pre.9, on macOS 14.5 23F79 darwin-arm64, locale zh-Hans-CN)
    ! Warning: `dart` on your path resolves to /opt/homebrew/Cellar/dart/3.1.0/libexec/bin/dart, which is not inside your current Flutter SDK
      checkout at /Users/zzz/development/flutter. Consider adding /Users/zzz/development/flutter/bin to the front of your path.
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.2.5)
[✓] VS Code (version 1.90.0)
[✓] Connected device (5 available)
    ! Error: Browsing on the local area network for 赵鲁滨的Apple Watch. Ensure the device is unlocked and discoverable via Bluetooth. (code -27)
    ! Error: Browsing on the local area network for 甘震的iPhone. Ensure the device is unlocked and attached with a cable or associated with the same
      local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources
@VijayakumarMariappan VijayakumarMariappan added charts Charts component open Open labels Jun 19, 2024
@PreethikaSelvam
Copy link
Contributor

Hi @elethiame,

Thank you for letting us know about this issue. We can replicate the reported issue regarding the range exception while enabling the data label builder while updating the data source with updateDataSource using a ChartSeriesController. This issue is scheduled to be fixed in our upcoming weekly patch release on July 2, 2024. We will update you here once the release is rolled out and we appreciate your patience until then.

Regards,

Preethika Selvam.

@VijayakumarMariappan VijayakumarMariappan added bug Something isn't working follow-up scheduled Follow-up scheduled and removed open Open labels Jun 20, 2024
@PreethikaSelvam
Copy link
Contributor

Hi @elethiame,

The reported issue is fixed, and the fix published in the below version. Therefore, we kindly request that you upgrade the syncfusion_flutter_charts package to the latest version below to avoid this issue.

Version: https://pub.dev/packages/syncfusion_flutter_charts/versions/26.1.40

Root cause: We stored and passed the chart points for the data label builder, but did not create real-time chart points, causing an index issue when using the builder.

Regards,

Preethika Selvam.

@VijayakumarMariappan VijayakumarMariappan added waiting for customer response Cannot make further progress until the customer responds. and removed follow-up scheduled Follow-up scheduled labels Jul 3, 2024
@elethiame
Copy link
Author

Thanks, the issue have been fixed.

@LavanyaGowtham2021 LavanyaGowtham2021 added fixed Fixed and delivered update and removed bug Something isn't working labels Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
charts Charts component fixed Fixed and delivered update waiting for customer response Cannot make further progress until the customer responds.
Projects
None yet
Development

No branches or pull requests

4 participants