filter and charts bug fix

This commit is contained in:
venbaittech 2025-03-21 18:08:31 +05:30
parent a1263877e0
commit 1c8515709a
4 changed files with 101 additions and 12 deletions

View File

@ -20,12 +20,12 @@ if (project.hasProperty('google-services.json')) {
def flutterVersionCode = localProperties.getProperty("flutter.versionCode") def flutterVersionCode = localProperties.getProperty("flutter.versionCode")
if (flutterVersionCode == null) { if (flutterVersionCode == null) {
flutterVersionCode = "41" flutterVersionCode = "42"
} }
def flutterVersionName = localProperties.getProperty("flutter.versionName") def flutterVersionName = localProperties.getProperty("flutter.versionName")
if (flutterVersionName == null) { if (flutterVersionName == null) {
flutterVersionName = "1.0.40" flutterVersionName = "1.0.41"
} }
def keystorePropertiesFile = rootProject.file("key.properties") def keystorePropertiesFile = rootProject.file("key.properties")

View File

@ -451,7 +451,8 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
///Calculate card Width ///Calculate card Width
Future<double?> _getWidget() async { Future<double?> _getWidget() async {
await Future.delayed(Duration(milliseconds: 50)); // Ensures widget is built await Future.delayed(Duration(milliseconds: 50)); // Ensures widget is built
final RenderBox? box = cardKey.currentContext?.findRenderObject() as RenderBox?; final RenderBox? box =
cardKey.currentContext?.findRenderObject() as RenderBox?;
if (box != null) { if (box != null) {
final Offset position = box.localToGlobal(Offset.zero); final Offset position = box.localToGlobal(Offset.zero);
@ -537,7 +538,7 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
final double screenHeight = MediaQuery.of(context).size.height; final double screenHeight = MediaQuery.of(context).size.height;
// print('remaintarget $remainHeight'); // print('remaintarget $remainHeight');
// print ('at intint target : ${screenHeight-remainHeight}'); // print ('at intint target : ${screenHeight-remainHeight}');
final double arrowPosition= screenHeight-tourCard; final double arrowPosition = screenHeight - tourCard;
marriageTargets = [ marriageTargets = [
TargetFocus( TargetFocus(
enableTargetTab: false, enableTargetTab: false,
@ -561,7 +562,7 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
child: Stack( child: Stack(
children: [ children: [
Positioned( Positioned(
bottom: arrowPosition*0.41, bottom: arrowPosition * 0.41,
left: 16, left: 16,
right: 16, right: 16,
child: Column( child: Column(
@ -871,7 +872,7 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
final double screenHeight = MediaQuery.of(context).size.height; final double screenHeight = MediaQuery.of(context).size.height;
// print('remaintarget $remainHeight'); // print('remaintarget $remainHeight');
// print ('at intint target : ${screenHeight-remainHeight}'); // print ('at intint target : ${screenHeight-remainHeight}');
final double arrowPosition= screenHeight-tourCard; final double arrowPosition = screenHeight - tourCard;
previousMarriageTargets = [ previousMarriageTargets = [
TargetFocus( TargetFocus(
enableTargetTab: false, enableTargetTab: false,
@ -1055,7 +1056,7 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
child: Stack( child: Stack(
children: [ children: [
Positioned( Positioned(
bottom: arrowPosition*0.41, bottom: arrowPosition * 0.41,
left: 16, left: 16,
right: 16, right: 16,
child: Column( child: Column(
@ -1794,6 +1795,9 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
Expanded( Expanded(
child: ElevatedButton( child: ElevatedButton(
onPressed: () { onPressed: () {
setState(() {
isLoading = true;
});
selectedFilters.forEach((filter) { selectedFilters.forEach((filter) {
filter["filter_data"].clear(); filter["filter_data"].clear();
}); });
@ -1849,6 +1853,7 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
"Selected Filters before applying: $selectedFilters"); "Selected Filters before applying: $selectedFilters");
setState(() { setState(() {
isLoading = true;
chartsData = originalTabChartsData; chartsData = originalTabChartsData;
cardData = originalTabCardData; cardData = originalTabCardData;
}); });

View File

@ -335,7 +335,70 @@ class ChartWidget extends StatelessWidget {
}).toList(); }).toList();
} }
List<Widget> generateIndicators(dynamic chartData) { // List<Widget> generateIndicators(dynamic chartData) {
// var groupByKeyValue;
// if (chartData['chart_type_json']['chart_type'] == 'bar_chart_horizontal' ||
// chartData['chart_type_json']['chart_type'] == 'horizontal_rotate') {
// groupByKeyValue = chartData['chart_type_json']['y_group'] ?? '';
// } else {
// groupByKeyValue = chartData['chart_type_json']['x_group'] ?? '';
// }
//
// return [
// Center(
// child: Wrap(
// alignment: WrapAlignment.center, // Center-align all items
// spacing: 10, // Adjust horizontal spacing
// runSpacing: 5, // Adjust vertical spacing for wrapping
// children: chartData['response'].asMap().entries.map<Widget>((entry) {
// int index = entry.key;
// var data = entry.value;
// Color color = Colors.primaries[index % Colors.primaries.length];
// String title = data['ObsKey'][groupByKeyValue] ?? '';
//
// return Container(
// padding: EdgeInsets.symmetric(vertical: 4), // Add spacing
// child: Row(
// mainAxisSize:
// MainAxisSize.min, // Wrap content without extra space
// mainAxisAlignment:
// MainAxisAlignment.center, // Align items center
// crossAxisAlignment:
// CrossAxisAlignment.center, // Align vertically
// children: [
// Container(
// width: 10,
// height: 10,
// decoration: BoxDecoration(
// color: uniqueColors[index % uniqueColors.length],
// shape: BoxShape.circle,
// ),
// ),
// SizedBox(width: 5),
// ConstrainedBox(
// constraints: BoxConstraints(
// maxWidth: 200, // Ensures text wraps within a limit
// ),
// child: Text(
// title,
// style: TextStyle(fontSize: 12),
// softWrap: true, // Allow text to wrap naturally
// textAlign: TextAlign.center, // Center text alignment
// ),
// ),
// ],
// ),
// );
// }).toList(),
// ),
// ),
// ];
// }
List<Widget> generateIndicators(
dynamic chartData,
double totalValue,
) {
var groupByKeyValue; var groupByKeyValue;
if (chartData['chart_type_json']['chart_type'] == 'bar_chart_horizontal' || if (chartData['chart_type_json']['chart_type'] == 'bar_chart_horizontal' ||
chartData['chart_type_json']['chart_type'] == 'horizontal_rotate') { chartData['chart_type_json']['chart_type'] == 'horizontal_rotate') {
@ -348,9 +411,30 @@ class ChartWidget extends StatelessWidget {
var data = entry.value; var data = entry.value;
Color color = Colors.primaries[index % Colors.primaries.length]; Color color = Colors.primaries[index % Colors.primaries.length];
String title = data['ObsKey'][groupByKeyValue] ?? ''; String title = data['ObsKey'][groupByKeyValue] ?? '';
// String value = data['ObsValue']['Value'].toString();
String shortTitle = String shortTitle =
title.length > 10 ? '${title.substring(0, 10)}' : title; title.length > 10 ? '${title.substring(0, 10)}' : title;
// Handle different types: int, double, and String
double value = 0.0;
var rawValue = data['ObsValue']['Value'];
if (rawValue is String) {
value = double.tryParse(rawValue) ?? 0.0;
} else if (rawValue is num) {
value = rawValue.toDouble();
} else if (rawValue is double) {
value = rawValue;
} else {
print('Unexpected Type for ObsValue[Value]: ${rawValue.runtimeType}');
}
// double percentage = (value / totalValue) * 100;
String percentage = (totalValue > 0)
? ((value / totalValue) * 100).toStringAsFixed(1)
: "0.0";
// bool isTouched = index == touchedIndex;
return Row( return Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
@ -376,9 +460,9 @@ class ChartWidget extends StatelessWidget {
message: title, // Full text on hover message: title, // Full text on hover
child: ConstrainedBox( child: ConstrainedBox(
// Constrain width to allow wrapping // Constrain width to allow wrapping
constraints: BoxConstraints(maxWidth: 200), constraints: BoxConstraints(maxWidth: 250),
child: Text( child: Text(
title, '$title -- $percentage%',
style: TextStyle( style: TextStyle(
fontSize: 12, fontSize: 12,
), ),
@ -630,7 +714,7 @@ class ChartWidget extends StatelessWidget {
child: Column( child: Column(
// Change Row to Column // Change Row to Column
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: generateIndicators(chartData), children: generateIndicators(chartData, totalValue),
), ),
), ),
), ),

View File

@ -1,7 +1,7 @@
name: uae_stat name: uae_stat
description: "View statistics about the UAE from the Federal Center for Statistics and Competitiveness." description: "View statistics about the UAE from the Federal Center for Statistics and Competitiveness."
publish_to: "none" publish_to: "none"
version: 1.0.40+41 version: 1.0.41+40
environment: environment:
sdk: ">=3.2.3 <4.0.0" sdk: ">=3.2.3 <4.0.0"