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. #5

Closed hongmono closed 2 years ago

hongmono commented 2 years ago

If I input the volume as 1, I get an error.

hongmono commented 2 years ago

I don't want to use Volume

h65wang commented 2 years ago

Set volumeHeightFactor: 0 to hide the volume portion.

InteractiveChart(..., style: ChartStyle(volumeHeightFactor: 0,...))

hongmono commented 2 years ago

If set it to volumeHeightFactor: 0, the volume chart is not visible. But still...

List<CandleData> data = MockDataTesla.rawData
  .map((row) => CandleData(
  timestamp: row[0] * 1000,
  open: row[1]?.toDouble(),
  high: row[2]?.toDouble(),
  low: row[3]?.toDouble(),
  close: row[4]?.toDouble(),
  volume: 0,
  ))
  .toList();

An error occurs when volume input is zeroed.

h65wang commented 2 years ago

I see, this happens when all values are equal.

A workaround (until it's fixed in a future version) is to randomly assign values to them: volume: Random().nextDouble(), ....

hongmono commented 2 years ago

Thanks it's works!