population chart issue fix

This commit is contained in:
venbaittech 2025-02-11 16:57:05 +05:30
parent 8bf645c65b
commit c0cbcf54fa
3 changed files with 60 additions and 34 deletions

View File

@ -15,12 +15,12 @@ if (localPropertiesFile.exists()) {
def flutterVersionCode = localProperties.getProperty("flutter.versionCode") def flutterVersionCode = localProperties.getProperty("flutter.versionCode")
if (flutterVersionCode == null) { if (flutterVersionCode == null) {
flutterVersionCode = "12" flutterVersionCode = "13"
} }
def flutterVersionName = localProperties.getProperty("flutter.versionName") def flutterVersionName = localProperties.getProperty("flutter.versionName")
if (flutterVersionName == null) { if (flutterVersionName == null) {
flutterVersionName = "1.0.11" flutterVersionName = "1.0.12"
} }
def keystorePropertiesFile = rootProject.file("key.properties") def keystorePropertiesFile = rootProject.file("key.properties")

View File

@ -538,7 +538,6 @@ class ChartWidget extends StatelessWidget {
color: groupColorMap[group], color: groupColorMap[group],
), ),
SizedBox(width: 6), SizedBox(width: 6),
Text( Text(
group, group,
style: TextStyle(fontSize: 14), style: TextStyle(fontSize: 14),
@ -615,17 +614,26 @@ class ChartWidget extends StatelessWidget {
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),
SizedBox(height: 10), SizedBox(height: 10),
// Chart
Expanded( Expanded(
child: LineChart(LineChartData( child: SingleChildScrollView(
lineTouchData: lineTouchData1(), scrollDirection: Axis.horizontal, // Enable horizontal scrolling
gridData: gridData(), padding: const EdgeInsets.only(right: 40),
titlesData: titlesData1(uniqueXValues), child: SizedBox(
borderData: borderData(), width: (uniqueXValues.length * 80) +
lineBarsData: lineBars, 80, // Adjust width dynamically
minX: uniqueXValues.reduce((a, b) => a < b ? a : b), child: LineChart(LineChartData(
maxX: uniqueXValues.reduce((a, b) => a > b ? a : b), 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(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Wrap( child: Wrap(
@ -649,7 +657,8 @@ class ChartWidget extends StatelessWidget {
); );
}).toList(), }).toList(),
), ),
), )
// Chart
]); ]);
case 'line_trend_2': case 'line_trend_2':
final List<Color> uniqueColorsLine_trend_2 = [ final List<Color> uniqueColorsLine_trend_2 = [
@ -794,22 +803,24 @@ class ChartWidget extends StatelessWidget {
getTitlesWidget: (value, meta) { getTitlesWidget: (value, meta) {
if (value.toInt() < xAxisData.length) { if (value.toInt() < xAxisData.length) {
String title = xAxisData[value.toInt()]; 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( return Padding(
padding: const EdgeInsets.only(top: 8.0), padding: const EdgeInsets.only(top: 8.0),
child: SizedBox( child: SizedBox(
width: 60, // Limit width to force wrapping width: 60, // Limit width to force wrapping
child: Transform.rotate( child: Transform.rotate(
angle: -0.5, angle: -0.5,
child:Tooltip( child: Tooltip(
message: title, message: title,
child: Text( child: Text(
displayTitle, displayTitle,
softWrap: true, softWrap: true,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
)),) )),
)); )));
} }
return Container(); return Container();
}, },
@ -959,6 +970,7 @@ class ChartWidget extends StatelessWidget {
crop = item['ObsKey']['SECTOR']; crop = item['ObsKey']['SECTOR'];
cropType = item['ObsKey'][groupByKey]; cropType = item['ObsKey'][groupByKey];
} else if (chartData['dataset'] == 'general_education') { } else if (chartData['dataset'] == 'general_education') {
print(chartData['dataset'] == 'general_education');
crop = item['ObsKey']['GENDER']; crop = item['ObsKey']['GENDER'];
cropType = item['ObsKey'][groupByKey]; cropType = item['ObsKey'][groupByKey];
} else if (chartData['dataset'] == 'higher_education') { } else if (chartData['dataset'] == 'higher_education') {
@ -1015,7 +1027,9 @@ class ChartWidget extends StatelessWidget {
String title = String title =
groupByValues.elementAt(value.toInt()); 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( return Padding(
padding: const EdgeInsets.only(top: 8.0), padding: const EdgeInsets.only(top: 8.0),
@ -1023,14 +1037,14 @@ class ChartWidget extends StatelessWidget {
width: 60, // Limit width to force wrapping width: 60, // Limit width to force wrapping
child: Transform.rotate( child: Transform.rotate(
angle: -0.5, angle: -0.5,
child:Tooltip( child: Tooltip(
message: title, message: title,
child: Text( child: Text(
displayTitle, displayTitle,
softWrap: true, softWrap: true,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
)),) )),
)); )));
// return Transform.rotate( // return Transform.rotate(
// angle: // angle:
// -0.5, // Rotation in radians (~ -30 degrees) // -0.5, // Rotation in radians (~ -30 degrees)
@ -1190,7 +1204,8 @@ class ChartWidget extends StatelessWidget {
touchTooltipData: BarTouchTooltipData( touchTooltipData: BarTouchTooltipData(
tooltipHorizontalAlignment: FLHorizontalAlignment.center, tooltipHorizontalAlignment: FLHorizontalAlignment.center,
tooltipRoundedRadius: 8, tooltipRoundedRadius: 8,
fitInsideHorizontally: true, // Ensure it fits within the screen fitInsideHorizontally:
true, // Ensure it fits within the screen
fitInsideVertically: true, fitInsideVertically: true,
tooltipPadding: EdgeInsets.all(8), tooltipPadding: EdgeInsets.all(8),
tooltipMargin: 16, tooltipMargin: 16,
@ -1992,8 +2007,19 @@ class ChartWidget extends StatelessWidget {
double value = double value =
double.tryParse(data['ObsValue']['Value'].toString()) ?? 0.0; double.tryParse(data['ObsValue']['Value'].toString()) ?? 0.0;
final barColor = uniqueColors[colorIndex % uniqueColors.length]; final List<Color> uniqueColorsForTwo = [
colorIndex++; 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( return BarChartRodData(
toY: value, // Use the parsed value toY: value, // Use the parsed value

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.11+12 version: 1.0.12+13
environment: environment:
sdk: ">=3.2.3 <4.0.0" sdk: ">=3.2.3 <4.0.0"