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

Exception when plotting line charts with starting/ending nan values #869

Closed
cristi-zz opened this issue Jan 6, 2022 · 4 comments
Closed

Comments

@cristi-zz
Copy link

Cheers and congrats on an amazing library!

I am plotting LineChartBarData that contains several NaN values at the beginning/ending of List

I got exception:

The following assertion was thrown during paint():
'package:fl_chart/src/utils/utils.dart': Failed assertion: line 182 pos 10: 'input >= 1.0': is not true.

The relevant error-causing widget was: 
  LineChart LineChart:file:///home/visoft/work/homeautoapp/lib/graphs.dart:104:19
When the exception was thrown, this was the stack: 
#2      _roundIntervalAboveOne (package:fl_chart/src/utils/utils.dart:182:10)
#3      roundInterval (package:fl_chart/src/utils/utils.dart:149:10)
#4      getEfficientInterval (package:fl_chart/src/utils/utils.dart:141:10)
#5      AxisChartPainter._drawGrid (package:fl_chart/src/chart/base/axis_chart/axis_chart_painter.dart:274:11)
#6      AxisChartPainter.paint (package:fl_chart/src/chart/base/axis_chart/axis_chart_painter.dart:41:5)
#7      LineChartPainter.paint (package:fl_chart/src/chart/line_chart/line_chart_painter.dart:80:11)
#8      RenderLineChart.paint (package:fl_chart/src/chart/line_chart/line_chart_renderer.dart:75:14)
#9      RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:2409:7)

Tried:
To add FlSpot.nullSpot, to add correct x value but double.nan for y.
However everything works fine if the null spots are "in the middle" of the series. Also works by adding dummy real values. But it defeats the purpose of showing that the data is missing (relevant)

Do I have workarounds?
Kind thanks!

Flutter Channel stable, 2.5.3, on Ubuntu 20.04.3
fl_chart: version: "0.40.6"

@cristi-zz
Copy link
Author

Workaround: Just remove all the nullSpots/nans. Drawback: data logic (eg axis, view windows is a bit harder) and missing data in the middle are "interpolated" with a line between known values. Not best, but ok given that I was in rush.

@Josutoral
Copy link

Tendrian que solucionar esto.

@imaNNeo
Copy link
Owner

imaNNeo commented Jan 28, 2022

Hi. As I explained in the issue template, It helps me a lot if you provide a reproducible code (in a main.dart function).

Thanks!

@imaNNeo
Copy link
Owner

imaNNeo commented Feb 12, 2022

Hi.
We have just fixed it in 0.45.0.
Please check it out!

@imaNNeo imaNNeo closed this as completed Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants