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

Cannot add FlSpot with same "y" in LineChart #879

Closed
HoseinHaqiqian opened this issue Jan 17, 2022 · 5 comments
Closed

Cannot add FlSpot with same "y" in LineChart #879

HoseinHaqiqian opened this issue Jan 17, 2022 · 5 comments
Labels
bug Something isn't working Line Chart

Comments

@HoseinHaqiqian
Copy link

Hi, i was going to add some Spot to the chart with same "y" and different "x".
but i ran into an error :

Unsupported operation: Result of truncating division is Infinity or NaN

#0      double._trunc_div (dart:core-patch/double.dart:56:57)
#1      double.~/ (dart:core-patch/double.dart:52:12)
#2      AxisChartPainter._drawGrid (package:fl_chart/src/chart/base/axis_chart/axis_chart_painter.dart:284:27)
#3      AxisChartPainter.paint (package:fl_chart/src/chart/base/axis_chart/axis_chart_painter.dart:40:5)
#4      LineChartPainter.paint (package:fl_chart/src/chart/line_chart/line_chart_painter.dart:79:11)
#5      RenderLineChart.paint (package:fl_chart/src/chart/line_chart/line_chart_renderer.dart:75:14)
#6      RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:2409:7)
#7      PaintingContext.paintChild (package:flutter/src/rendering/object.dart:189:13)

i'm using fl_chart : ^0.41.0

@HoseinHaqiqian HoseinHaqiqian changed the title Cannot add FlSpot with only "x" difference in LineChart Cannot add FlSpot with same "y" in LineChart Jan 17, 2022
@iambaofeng
Copy link

i have the same question,when i use data like x:['2021-08','2021-09','2121-10','2021-11','2021-12','2022-01'] y:[0.0,0.0,0.0,0.0,0.0,0.0,0.0] it will catch a error ,like this=>
image

@erlangparasu
Copy link

same problem

@erlangparasu
Copy link

how to solve: maxY must greater than 0 minY
so i calculate manually and return default value for maxY

    int maxValue = 0;
    for (var item in myListValue) {
      if (item > maxValue) {
        maxValue = a;
      }
    }

    if (maxValue == 0) {
      maxValue = 10;
    }

    return LineChartData(
      // lineTouchData: lineTouchData1,
      // gridData: gridData,
      // titlesData: titlesData1,
      // borderData: borderData,
      // lineBarsData: ...,
      // minX: ...,
      // maxX: ...,
      minY: 0.toDouble(),
      maxY: maxValue.toDouble(),
    );

@imaNNeo
Copy link
Owner

imaNNeo commented Jan 28, 2022

As I explained in the issue template, Please provide me a reproducible code (a main.dart file).

@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
@imaNNeo imaNNeo added bug Something isn't working Line Chart and removed Needs Reproducible Code labels Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Line Chart
Projects
None yet
Development

No branches or pull requests

4 participants