I am new to Flutter and just started using fl_charts
which really looks fantastic. However I am struggling to move beyond demo LineChartSample1.
The sample code given here assigns values to spots as follows:
spots: [
FlSpot(1, 1.4),
FlSpot(2, 3.4),
FlSpot(3, 2),
FlSpot(4, 2.2),
FlSpot(5, 1.8),
],
In real life this obviously will have to be dynamic. Hence I need to assign values from an array of numbers like this:
myArray = [7578, 7547, 3578, 9875]
I can't figure out how to assign this array to spots assuming that first parameter to FlSpot is just a sequence like 0, 1, 2, 3 ... and second parameter coming from myArray.
I need something like FlSpot(x++, myArray[x])
in a loop.