imaNNeo / fl_chart

FL Chart is a highly customizable Flutter chart library that supports Line Chart, Bar Chart, Pie Chart, Scatter Chart, and Radar Chart.
https://flchart.dev
MIT License
6.77k stars 1.74k forks source link

Exception: indicatorsData and touchedSpotOffsets size should be same. need help pls. #1601

Open sid-Dbot opened 7 months ago

sid-Dbot commented 7 months ago

Getting Exception: indicatorsData and touchedSpotOffsets size should be same. here's my code:

return MaterialApp( home: Scaffold( backgroundColor: Color(0xFFF0F2F6), body: Center( child: Container( padding: const EdgeInsets.all(10), width: double.infinity, height: 200, child: LineChart( // curve: Curves.easeInCubic, LineChartData( lineTouchData: LineTouchData( getTouchLineEnd: (barData, spotIndex) => barData.spots[spotIndex].y + 1000000, getTouchLineStart: (barData, spotIndex) => 0, getTouchedSpotIndicator: (barData, spotIndexes) => [ TouchedSpotIndicatorData( FlLine( dashArray: [4, 4], color: Colors.grey, ), FlDotData()) ], touchTooltipData: LineTouchTooltipData( maxContentWidth: 150, tooltipRoundedRadius: 8, fitInsideHorizontally: true, fitInsideVertically: true, tooltipBgColor: Colors.white, getTooltipItems: (touchedSpots) { return [ LineTooltipItem( 'May 9, 2023', TextStyle( color: Colors.grey, fontSize: 10, fontWeight: FontWeight.w400), children: [ TextSpan(text: '\nBalance'), TextSpan( text: "\nRs. ${touchedSpots[0].y.toString()}", style: TextStyle( color: Colors.black, fontSize: 12, fontWeight: FontWeight.w500)) ]), ]; }, )), titlesData: FlTitlesData(show: false), gridData: FlGridData(show: false), borderData: FlBorderData(show: false), lineBarsData: [ LineChartBarData( // preventCurveOverShooting: true, dotData: FlDotData(show: false), isCurved: true, color: Color(0xff0B72EB), spots: data, ) ]), ), ), ), ), );

iamnabink commented 6 months ago

Flutter version? Package version? Steps to reproduce..? Add more detailed information please

sid-Dbot commented 6 months ago

fl_chart: ^0.66.2 Flutter 3.19.0 the exception occurs every time the indicator in the chart is moved or intereracted with.

imaNNeo commented 5 months ago

Hi, can you please provide us with a reproducible code? (a main.dart file content that runs without any dependency)