fluttercandies / flutter-interactive-chart

A candlestick chart that supports pinch-to-zoom and panning.
https://pub.dev/packages/interactive_chart
MIT License
209 stars 66 forks source link

Offset argument contained a NaN value, happens when maxPrice and minPrice are equal #14

Open siva2204 opened 2 years ago

siva2204 commented 2 years ago
'dart:ui/painting.dart':
Failed assertion: line 52 pos 10: '<optimized out>'

ig this happens when maxPrice and minPrice are the same in a set of data. this happens in fitPrice function

  double fitPrice(double y) =>
      priceHeight * (maxPrice - y) / (maxPrice - minPrice);

and thanks for the amazing package!

finitelooping commented 2 years ago
'dart:ui/painting.dart':
Failed assertion: line 52 pos 10: '<optimized out>'

ig this happens when maxPrice and minPrice are the same in a set of data. this happens in fitPrice function

  double fitPrice(double y) =>
      priceHeight * (maxPrice - y) / (maxPrice - minPrice);

and thanks for the amazing package!

I have 2 similar issues to siva2204's.

1)

════════ Exception caught by widgets library ═══════════════════════════════════ Cannot interpolate between finite and non-finite values 'dart:ui/lerp.dart': Failed assertion: line 20 pos 10: ''

The relevant error-causing widget was InteractiveChart lib\…\components\interact_chart.dart:98 ════════════════════════════════════════════════════════════════════════════════

2) ════════ Exception caught by rendering library ═════════════════════════════════ The following assertion was thrown during paint(): Offset argument contained a NaN value. 'dart:ui/painting.dart': Failed assertion: line 52 pos 10: ''

The relevant error-causing widget was InteractiveChart lib\…\components\interact_chart.dart:98 When the exception was thrown, this was the stack

2 _offsetIsValid (dart:ui/painting.dart:52:10)

3 Canvas.drawLine (dart:ui/painting.dart:4167:12)

4 ChartPainter._drawPriceGridAndLabels.

package:interactive_chart/src/chart_painter.dart:87

5 ListIterable.forEach (dart:_internal/iterable.dart:39:13)

6 ChartPainter._drawPriceGridAndLabels

package:interactive_chart/src/chart_painter.dart:86 ... The following RenderObject was being processed when the exception was fired: RenderCustomPaint#7f86c relayoutBoundary=up7 RenderObject: RenderCustomPaint#7f86c relayoutBoundary=up7 parentData: (can use size) constraints: BoxConstraints(0.0<=w<=797.7, 0.0<=h<=307.4) size: Size(797.7, 307.4)