From c0cbcf54fa25b3bc6169380a784ef59c5d111dea Mon Sep 17 00:00:00 2001 From: venbaittech Date: Tue, 11 Feb 2025 16:57:05 +0530 Subject: [PATCH] population chart issue fix --- android/app/build.gradle | 4 +- .../Screens/charts/widgets/chart_widget.dart | 88 ++++++++++++------- pubspec.yaml | 2 +- 3 files changed, 60 insertions(+), 34 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 1359f22c..7f89f75b 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -15,12 +15,12 @@ if (localPropertiesFile.exists()) { def flutterVersionCode = localProperties.getProperty("flutter.versionCode") if (flutterVersionCode == null) { - flutterVersionCode = "12" + flutterVersionCode = "13" } def flutterVersionName = localProperties.getProperty("flutter.versionName") if (flutterVersionName == null) { - flutterVersionName = "1.0.11" + flutterVersionName = "1.0.12" } def keystorePropertiesFile = rootProject.file("key.properties") diff --git a/lib/presentation/Screens/charts/widgets/chart_widget.dart b/lib/presentation/Screens/charts/widgets/chart_widget.dart index 59321013..9a9b4553 100644 --- a/lib/presentation/Screens/charts/widgets/chart_widget.dart +++ b/lib/presentation/Screens/charts/widgets/chart_widget.dart @@ -538,7 +538,6 @@ class ChartWidget extends StatelessWidget { color: groupColorMap[group], ), SizedBox(width: 6), - Text( group, style: TextStyle(fontSize: 14), @@ -615,17 +614,26 @@ class ChartWidget extends StatelessWidget { textAlign: TextAlign.center, ), SizedBox(height: 10), - // Chart + Expanded( - child: LineChart(LineChartData( - lineTouchData: lineTouchData1(), - gridData: gridData(), - titlesData: titlesData1(uniqueXValues), - borderData: borderData(), - lineBarsData: lineBars, - minX: uniqueXValues.reduce((a, b) => a < b ? a : b), - maxX: uniqueXValues.reduce((a, b) => a > b ? a : b), - ))), + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, // Enable horizontal scrolling + padding: const EdgeInsets.only(right: 40), + child: SizedBox( + width: (uniqueXValues.length * 80) + + 80, // Adjust width dynamically + child: LineChart(LineChartData( + lineTouchData: lineTouchData1(), + gridData: gridData(), + titlesData: titlesData1(uniqueXValues), + borderData: borderData(), + lineBarsData: lineBars, + minX: uniqueXValues.reduce((a, b) => a < b ? a : b), + maxX: uniqueXValues.reduce((a, b) => a > b ? a : b), + )), + ), + ), + ), Padding( padding: const EdgeInsets.all(8.0), child: Wrap( @@ -649,7 +657,8 @@ class ChartWidget extends StatelessWidget { ); }).toList(), ), - ), + ) + // Chart ]); case 'line_trend_2': final List uniqueColorsLine_trend_2 = [ @@ -794,22 +803,24 @@ class ChartWidget extends StatelessWidget { getTitlesWidget: (value, meta) { if (value.toInt() < xAxisData.length) { String title = xAxisData[value.toInt()]; - String displayTitle = title.length > 10 ? title.substring(0, 10) + '...' : title; + String displayTitle = title.length > 10 + ? title.substring(0, 10) + '...' + : title; return Padding( padding: const EdgeInsets.only(top: 8.0), child: SizedBox( - width: 60, // Limit width to force wrapping - child: Transform.rotate( - angle: -0.5, - child:Tooltip( - message: title, - child: Text( - displayTitle, - softWrap: true, - overflow: TextOverflow.ellipsis, - )),) - )); + width: 60, // Limit width to force wrapping + child: Transform.rotate( + angle: -0.5, + child: Tooltip( + message: title, + child: Text( + displayTitle, + softWrap: true, + overflow: TextOverflow.ellipsis, + )), + ))); } return Container(); }, @@ -959,6 +970,7 @@ class ChartWidget extends StatelessWidget { crop = item['ObsKey']['SECTOR']; cropType = item['ObsKey'][groupByKey]; } else if (chartData['dataset'] == 'general_education') { + print(chartData['dataset'] == 'general_education'); crop = item['ObsKey']['GENDER']; cropType = item['ObsKey'][groupByKey]; } else if (chartData['dataset'] == 'higher_education') { @@ -1015,7 +1027,9 @@ class ChartWidget extends StatelessWidget { String title = groupByValues.elementAt(value.toInt()); - String displayTitle = title.length > 10 ? title.substring(0, 10) + '...' : title; + String displayTitle = title.length > 10 + ? title.substring(0, 10) + '...' + : title; return Padding( padding: const EdgeInsets.only(top: 8.0), @@ -1023,14 +1037,14 @@ class ChartWidget extends StatelessWidget { width: 60, // Limit width to force wrapping child: Transform.rotate( angle: -0.5, - child:Tooltip( + child: Tooltip( message: title, child: Text( displayTitle, softWrap: true, overflow: TextOverflow.ellipsis, - )),) - )); + )), + ))); // return Transform.rotate( // angle: // -0.5, // Rotation in radians (~ -30 degrees) @@ -1190,7 +1204,8 @@ class ChartWidget extends StatelessWidget { touchTooltipData: BarTouchTooltipData( tooltipHorizontalAlignment: FLHorizontalAlignment.center, tooltipRoundedRadius: 8, - fitInsideHorizontally: true, // Ensure it fits within the screen + fitInsideHorizontally: + true, // Ensure it fits within the screen fitInsideVertically: true, tooltipPadding: EdgeInsets.all(8), tooltipMargin: 16, @@ -1992,8 +2007,19 @@ class ChartWidget extends StatelessWidget { double value = double.tryParse(data['ObsValue']['Value'].toString()) ?? 0.0; - final barColor = uniqueColors[colorIndex % uniqueColors.length]; - colorIndex++; + final List uniqueColorsForTwo = [ + Color(0xFF648CBA), + Color(0xFF90B0D5), + ]; + final barColor; + if (chartData['dataset'] == 'general_education' || + chartData['dataset'] == 'higher_education') { + barColor = uniqueColorsForTwo[colorIndex % uniqueColorsForTwo.length]; + colorIndex++; + } else { + barColor = uniqueColors[colorIndex % uniqueColors.length]; + colorIndex++; + } return BarChartRodData( toY: value, // Use the parsed value diff --git a/pubspec.yaml b/pubspec.yaml index b275930a..eea7fbf6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: uae_stat description: "View statistics about the UAE from the Federal Center for Statistics and Competitiveness." publish_to: "none" -version: 1.0.11+12 +version: 1.0.12+13 environment: sdk: ">=3.2.3 <4.0.0"