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

Offset argument contained a NaN value #18

Closed
papakay opened this issue Jan 24, 2019 · 4 comments
Closed

Offset argument contained a NaN value #18

papakay opened this issue Jan 24, 2019 · 4 comments
Assignees

Comments

@papakay
Copy link

papakay commented Jan 24, 2019

Hi, I want to really commend the great work done so far with this library.

I experience the error above when i have data rows as below

_chartData.dataRows = [
      [0.0, 0.0, 0.0, 0.0, 0.0],
      [0.0, 0.0, 0.0, 0.0, 0.0],
      [0.0, 0.0, 0.0, 0.0, 0.0],
      [0.0, 0.0, 0.0, 0.0, 0.0],
    ];

Part of the error message:

flutter: ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
flutter: The following assertion was thrown during paint():
flutter: Offset argument contained a NaN value.
flutter: 'dart:ui/painting.dart': Failed assertion: line 38: '<optimized out>'
flutter:
flutter: Either the assertion indicates an error in the framework itself, or we should provide substantially
flutter: more information in this error message to help you determine and fix the underlying cause.
flutter: In either case, please report this assertion by filing a bug on GitHub:
flutter:   https://github.com/flutter/flutter/issues/new?template=BUG.md
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #2      _offsetIsValid (dart:ui/painting.dart:38:10)
flutter: #3      Canvas.drawLine (dart:ui/painting.dart:3146:12)
flutter: #4      LineContainer.paint (package:flutter_charts/src/chart/line_container.dart:20:12)
flutter: #5      GridLinesContainer.paint.<anonymous closure> (package:flutter_charts/src/chart/container.dart:1094:62)
flutter: #6      List.forEach (dart:core/runtime/libgrowable_array.dart:277:8)
flutter: #7      GridLinesContainer.paint (package:flutter_charts/src/chart/container.dart:1094:21)
flutter: #8      DataContainer.paint (package:flutter_charts/src/chart/container.dart:1028:31)
flutter: #9      ChartPainter.drawGrid (package:flutter_charts/src/chart/painter.dart:76:29)
flutter: #10     ChartPainter.paint (package:flutter_charts/src/chart/painter.dart:55:5)
flutter: #11     RenderCustomPaint._paintWithPainter (package:flutter/src/rendering/custom_paint.dart:521:13)
flutter: #12     RenderCustomPaint.paint (package:flutter/src/rendering/custom_paint.dart:559:7)
flutter: #13     RenderObject._paintWithContext
@ruan65
Copy link

ruan65 commented Nov 29, 2019

mee too

@mzimmerm mzimmerm self-assigned this Dec 19, 2021
Repository owner deleted a comment from vikramacn5 Dec 19, 2021
@mzimmerm
Copy link
Owner

@papakay : Thanks very much for reporting this, and my appologies for the delay. If still relevant: This "all zeros issue" is now fixed in the latest version 0.3.1. Please take a look at

https://pub.dev/packages/flutter_charts/changelog

An example that failed before the change and is now fixed can be seen in

https://github.com/mzimmerm/flutter_charts/blob/master/example1/lib/main.dart

around

      case ExamplesEnum.ex900ErrorFixUserDataAllZero:
        /// Currently, setting [ChartDate.dataRows] requires to also set all of 
        /// [chartData.xLabels], [chartData.dataRowsLegends], [chartData.dataRowsColors]
        // Fix was: Add default legend to ChartData constructor AND fix scaling util_dart.dart scaleValue.
        chartData = ChartData();
        chartData.dataRows = [
          [0.0, 0.0, 0.0],
        ];
        // Note: When ChartData is defined, 
        //       ALL OF  chartData.xLabels,  chartData.dataRowsLegends, chartData.dataRowsColors
        //       must be set by client
        chartData.xLabels = ['Wolf', 'Deer', 'Mouse'];
        chartData.dataRowsLegends = [
          'Row 1',
        ];
        chartData.dataRowsColors = [
          Colors.blue,
        ];

@mzimmerm
Copy link
Owner

@papakay Thanks again for reporting this issue. As this is now working (as of 0.3.1) I will go ahead and close this item.

@papakay
Copy link
Author

papakay commented Jan 11, 2022

Thanks a lot @mzimmerm for the great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants