Fl_chart: Doesnt' work with big data

Created on 3 Aug 2019  路  10Comments  路  Source: imaNNeoFighT/fl_chart

Currently,
I'm fetching the data from this API (https://api.coincap.io/v2/assets/bitcoin/history?interval=d1)

I created a FlSpot with these values:
FlSpot(2757.4283650019844275, 1501718400000.1)

The chart doesn't work and the app stops working as well.

bug

Most helpful comment

@andynguy3n @tauitdnmd I was having similar issue, when large data is passed app becomes unresponsive and might crash too.
Instead of passing values directly to chart calculate the percentage of each value between 0-100 then use it in fl_chart.

All 10 comments

I'm having the same issue too.
It doesn't work with a big value.

@andynguy3n @tauitdnmd I was having similar issue, when large data is passed app becomes unresponsive and might crash too.
Instead of passing values directly to chart calculate the percentage of each value between 0-100 then use it in fl_chart.

Same issue

Sore for delay, I've tried with the values that you said:

And it works just fine!

May I ask you use the latest version of fl_chart, and check it again?

It's gonna be closed if I don't get any answer in a day because I tested it and it works in new versions.

Thanks @imaNNeoFighT ,
I'll test it again soon.

Unfortunately, I'm gonna close it soon

Hi @imaNNeoFighT

I think with this number it doesn't work
1506124800000.0

Since the Unix timestamp is int, I covert to double by using this function

  List<FlSpot> listSpots() => this.data.map((assetData) {
        return FlSpot(
          assetData.time.roundToDouble(),
          double.parse(assetData.priceUsd),
        );
      }).toList();

Then try with 5 items

  @override
  Widget build(BuildContext context) {
    return FlChart(
      chart: LineChart(
        LineChartData(
          lineBarsData: [
            LineChartBarData(
                spots: listSpots().take(5).toList(),
                isCurved: true,
                isStrokeCapRound: false)
          ],
        ),
      ),
    );
  }

Screen Shot 2019-09-20 at 10 10 36 PM

Hi guys, I know your problem, but not sure what could we do,
I think you guys can scale down your values to fix this problem, is it works?

Thanks. I'll try. Have a good day.

Was this page helpful?
0 / 5 - 0 ratings