12/28/1
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:fl_chart/fl_chart.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:ride/constant/links.dart';
|
import 'package:ride/constant/links.dart';
|
||||||
import 'package:ride/controller/functions/crud.dart';
|
import 'package:ride/controller/functions/crud.dart';
|
||||||
@@ -12,26 +11,27 @@ class RideAdminController extends GetxController {
|
|||||||
late List<RideData> rideData;
|
late List<RideData> rideData;
|
||||||
late Map<String, dynamic> jsonResponse;
|
late Map<String, dynamic> jsonResponse;
|
||||||
List<dynamic> ridesDetails = [];
|
List<dynamic> ridesDetails = [];
|
||||||
var chartData;
|
// var chartData;
|
||||||
|
late List<ChartDataS> chartDatasync;
|
||||||
Future getRidesAdminDash() async {
|
Future getRidesAdminDash() async {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
update();
|
update();
|
||||||
var res = await CRUD().get(link: AppLink.getRidesPerMonth, payload: {});
|
var res = await CRUD().get(link: AppLink.getRidesPerMonth, payload: {});
|
||||||
jsonResponse = jsonDecode(res);
|
jsonResponse = jsonDecode(res);
|
||||||
rideData = (jsonResponse['message'] as List)
|
|
||||||
.map((item) => RideData.fromJson(item))
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
chartData = rideData
|
chartDatasync = (jsonResponse['message'] as List)
|
||||||
.map((data) => FlSpot(data.day.toDouble(), data.ridesCount.toDouble()))
|
.map((item) => ChartDataS(
|
||||||
|
item['year'],
|
||||||
|
item['month'],
|
||||||
|
item['day'],
|
||||||
|
item['rides_count'],
|
||||||
|
))
|
||||||
.toList();
|
.toList();
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getRidesDetails() async {
|
Future getRidesDetails() async {
|
||||||
isLoading = true;
|
|
||||||
update();
|
|
||||||
var res = await CRUD().get(link: AppLink.getRidesDetails, payload: {});
|
var res = await CRUD().get(link: AppLink.getRidesDetails, payload: {});
|
||||||
|
|
||||||
var d = jsonDecode(res);
|
var d = jsonDecode(res);
|
||||||
@@ -42,9 +42,22 @@ class RideAdminController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() async {
|
||||||
getRidesAdminDash();
|
List<Future> initializationTasks = [
|
||||||
getRidesDetails();
|
getRidesAdminDash(),
|
||||||
|
getRidesDetails(),
|
||||||
|
];
|
||||||
|
// cameras = await availableCameras();
|
||||||
|
await Future.wait(initializationTasks);
|
||||||
super.onInit();
|
super.onInit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ChartDataS {
|
||||||
|
ChartDataS(this.year, this.month, this.day, this.ridesCount);
|
||||||
|
|
||||||
|
final int year;
|
||||||
|
final int month;
|
||||||
|
final int day;
|
||||||
|
final int ridesCount;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import 'package:fl_chart/fl_chart.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:ride/constant/colors.dart';
|
import 'package:ride/constant/colors.dart';
|
||||||
import 'package:ride/constant/style.dart';
|
import 'package:ride/constant/style.dart';
|
||||||
import 'package:ride/views/widgets/my_scafold.dart';
|
import 'package:ride/views/widgets/my_scafold.dart';
|
||||||
import 'package:ride/views/widgets/mycircular.dart';
|
import 'package:ride/views/widgets/mycircular.dart';
|
||||||
|
import 'package:syncfusion_flutter_charts/charts.dart';
|
||||||
|
|
||||||
import '../../../controller/admin/ride_admin_controller.dart';
|
import '../../../controller/admin/ride_admin_controller.dart';
|
||||||
|
|
||||||
@@ -19,96 +19,137 @@ class Rides extends StatelessWidget {
|
|||||||
? const Center(child: MyCircularProgressIndicator())
|
? const Center(child: MyCircularProgressIndicator())
|
||||||
: Column(
|
: Column(
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
|
||||||
height: Get.height * .4,
|
|
||||||
child: LineChart(
|
|
||||||
duration: const Duration(milliseconds: 150),
|
|
||||||
curve: Curves.ease,
|
|
||||||
LineChartData(
|
|
||||||
lineBarsData: [
|
|
||||||
LineChartBarData(
|
|
||||||
spots: rideAdminController.chartData,
|
|
||||||
isCurved: true,
|
|
||||||
color: Colors.deepPurpleAccent, // Custom color
|
|
||||||
barWidth: 3, // Thinner line
|
|
||||||
dotData: const FlDotData(
|
|
||||||
show: true), // Show dots on each point
|
|
||||||
belowBarData: BarAreaData(
|
|
||||||
// Add gradient fill below the line
|
|
||||||
show: true,
|
|
||||||
color: AppColor.deepPurpleAccent,
|
|
||||||
),
|
|
||||||
isStrokeJoinRound: true,
|
|
||||||
shadow: const BoxShadow(
|
|
||||||
color: AppColor.yellowColor,
|
|
||||||
blurRadius: 4,
|
|
||||||
offset: Offset(2, 2),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
showingTooltipIndicators: const [],
|
|
||||||
titlesData: FlTitlesData(
|
|
||||||
show: true,
|
|
||||||
topTitles: AxisTitles(
|
|
||||||
axisNameWidget: Text(
|
|
||||||
'Days',
|
|
||||||
style: AppStyle.title,
|
|
||||||
),
|
|
||||||
axisNameSize: 30,
|
|
||||||
sideTitles: const SideTitles(
|
|
||||||
reservedSize: 30, showTitles: true)),
|
|
||||||
bottomTitles: AxisTitles(
|
|
||||||
axisNameWidget: Text(
|
|
||||||
'Total Trips on month'.tr,
|
|
||||||
style: AppStyle.title,
|
|
||||||
),
|
|
||||||
axisNameSize: 30,
|
|
||||||
sideTitles: const SideTitles(
|
|
||||||
reservedSize: 30, showTitles: true)),
|
|
||||||
leftTitles: AxisTitles(
|
|
||||||
axisNameWidget: Text(
|
|
||||||
'Counts of Trips on month'.tr,
|
|
||||||
style: AppStyle.title,
|
|
||||||
),
|
|
||||||
axisNameSize: 30,
|
|
||||||
sideTitles: const SideTitles(
|
|
||||||
reservedSize: 30, showTitles: true)),
|
|
||||||
),
|
|
||||||
gridData: const FlGridData(
|
|
||||||
show: true,
|
|
||||||
),
|
|
||||||
borderData: FlBorderData(
|
|
||||||
show: true,
|
|
||||||
border: const Border(
|
|
||||||
bottom: BorderSide(color: AppColor.accentColor),
|
|
||||||
left: BorderSide(color: AppColor.accentColor),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// SizedBox(
|
// SizedBox(
|
||||||
// height: Get.height * .4,
|
// height: Get.height * .4,
|
||||||
// child: PieChart(
|
// child: LineChart(
|
||||||
// PieChartData(
|
// duration: const Duration(milliseconds: 150),
|
||||||
// sectionsSpace: 4, // Adjust spacing between sections
|
// curve: Curves.ease,
|
||||||
// centerSpaceRadius:
|
// LineChartData(
|
||||||
// 40, // Adjust radius of center space
|
// lineBarsData: [
|
||||||
// sections: [
|
// LineChartBarData(
|
||||||
// for (final rideData in rideAdminController.rideData)
|
// spots: rideAdminController.chartData,
|
||||||
// PieChartSectionData(
|
// isCurved: true,
|
||||||
// value: rideData.ridesCount.toDouble(),
|
// color: Colors.deepPurpleAccent, // Custom color
|
||||||
// title: '${rideData.day}', showTitle: true,
|
// barWidth: 3, // Thinner line
|
||||||
// titleStyle:
|
// dotData: const FlDotData(
|
||||||
// AppStyle.subtitle, // Display day as title
|
// show: true), // Show dots on each point
|
||||||
// radius: 60, // Adjust radius of each section
|
// belowBarData: BarAreaData(
|
||||||
// color:
|
// // Add gradient fill below the line
|
||||||
// AppColor.deepPurpleAccent, // Custom color
|
// show: true,
|
||||||
|
// color: AppColor.deepPurpleAccent,
|
||||||
|
// ),
|
||||||
|
// isStrokeJoinRound: true,
|
||||||
|
// shadow: const BoxShadow(
|
||||||
|
// color: AppColor.yellowColor,
|
||||||
|
// blurRadius: 4,
|
||||||
|
// offset: Offset(2, 2),
|
||||||
|
// ),
|
||||||
// ),
|
// ),
|
||||||
// ],
|
// ],
|
||||||
|
// showingTooltipIndicators: const [],
|
||||||
|
// titlesData: FlTitlesData(
|
||||||
|
// show: true,
|
||||||
|
// topTitles: AxisTitles(
|
||||||
|
// axisNameWidget: Text(
|
||||||
|
// 'Days',
|
||||||
|
// style: AppStyle.title,
|
||||||
|
// ),
|
||||||
|
// axisNameSize: 30,
|
||||||
|
// sideTitles: const SideTitles(
|
||||||
|
// reservedSize: 30, showTitles: true)),
|
||||||
|
// bottomTitles: AxisTitles(
|
||||||
|
// axisNameWidget: Text(
|
||||||
|
// 'Total Trips on month'.tr,
|
||||||
|
// style: AppStyle.title,
|
||||||
|
// ),
|
||||||
|
// axisNameSize: 30,
|
||||||
|
// sideTitles: const SideTitles(
|
||||||
|
// reservedSize: 30, showTitles: true)),
|
||||||
|
// leftTitles: AxisTitles(
|
||||||
|
// axisNameWidget: Text(
|
||||||
|
// 'Counts of Trips on month'.tr,
|
||||||
|
// style: AppStyle.title,
|
||||||
|
// ),
|
||||||
|
// axisNameSize: 30,
|
||||||
|
// sideTitles: const SideTitles(
|
||||||
|
// reservedSize: 30, showTitles: true)),
|
||||||
|
// ),
|
||||||
|
// gridData: const FlGridData(
|
||||||
|
// show: true,
|
||||||
|
// ),
|
||||||
|
// borderData: FlBorderData(
|
||||||
|
// show: true,
|
||||||
|
// border: const Border(
|
||||||
|
// bottom: BorderSide(color: AppColor.accentColor),
|
||||||
|
// left: BorderSide(color: AppColor.accentColor),
|
||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// // SizedBox(
|
||||||
|
// // height: Get.height * .4,
|
||||||
|
// // child: PieChart(
|
||||||
|
// // PieChartData(
|
||||||
|
// // sectionsSpace: 4, // Adjust spacing between sections
|
||||||
|
// // centerSpaceRadius:
|
||||||
|
// // 40, // Adjust radius of center space
|
||||||
|
// // sections: [
|
||||||
|
// // for (final rideData in rideAdminController.rideData)
|
||||||
|
// // PieChartSectionData(
|
||||||
|
// // value: rideData.ridesCount.toDouble(),
|
||||||
|
// // title: '${rideData.day}', showTitle: true,
|
||||||
|
// // titleStyle:
|
||||||
|
// // AppStyle.subtitle, // Display day as title
|
||||||
|
// // radius: 60, // Adjust radius of each section
|
||||||
|
// // color:
|
||||||
|
// // AppColor.deepPurpleAccent, // Custom color
|
||||||
|
// // ),
|
||||||
|
// // ],
|
||||||
|
// // ),
|
||||||
|
// // ),
|
||||||
|
// // ),
|
||||||
|
|
||||||
|
SizedBox(
|
||||||
|
// height: 400,
|
||||||
|
child: SfCartesianChart(
|
||||||
|
legend: const Legend(
|
||||||
|
isVisible: true,
|
||||||
|
position: LegendPosition.bottom,
|
||||||
|
overflowMode: LegendItemOverflowMode.wrap,
|
||||||
|
textStyle: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
borderWidth: 2,
|
||||||
|
borderColor: AppColor.blueColor,
|
||||||
|
plotAreaBorderColor: AppColor.deepPurpleAccent,
|
||||||
|
enableAxisAnimation: true,
|
||||||
|
primaryXAxis: CategoryAxis(
|
||||||
|
borderColor: AppColor.accentColor, borderWidth: 2,
|
||||||
|
title: AxisTitle(
|
||||||
|
text: 'Total Trips on month'.tr,
|
||||||
|
textStyle: AppStyle.title,
|
||||||
|
),
|
||||||
|
// labelRotation: 45,
|
||||||
|
majorGridLines: const MajorGridLines(width: 0),
|
||||||
|
),
|
||||||
|
primaryYAxis: const NumericAxis(isVisible: false),
|
||||||
|
series: <LineSeries<ChartDataS, String>>[
|
||||||
|
LineSeries<ChartDataS, String>(
|
||||||
|
dataSource: rideAdminController.chartDatasync,
|
||||||
|
xValueMapper: (ChartDataS data, _) => '${data.day}',
|
||||||
|
yValueMapper: (ChartDataS data, _) =>
|
||||||
|
data.ridesCount,
|
||||||
|
dataLabelSettings:
|
||||||
|
const DataLabelSettings(isVisible: true),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
|
|||||||
32
pubspec.lock
32
pubspec.lock
@@ -361,14 +361,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.5.2"
|
version: "0.5.2"
|
||||||
equatable:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: equatable
|
|
||||||
sha256: c2b87cb7756efdf69892005af546c56c0b5037f54d2a88269b4f347a505e3ca2
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.0.5"
|
|
||||||
fake_async:
|
fake_async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -481,14 +473,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0"
|
version: "1.1.0"
|
||||||
fl_chart:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: fl_chart
|
|
||||||
sha256: "5a74434cc83bf64346efb562f1a06eefaf1bcb530dc3d96a104f631a1eff8d79"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.65.0"
|
|
||||||
flutter:
|
flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -1581,6 +1565,22 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "9.5.0+1"
|
version: "9.5.0+1"
|
||||||
|
syncfusion_flutter_charts:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: syncfusion_flutter_charts
|
||||||
|
sha256: "12ed32b889bd4a28cf44b9fa246510e8f2fc798023018a6a915cbd0bffec1517"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "24.1.43"
|
||||||
|
syncfusion_flutter_core:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: syncfusion_flutter_core
|
||||||
|
sha256: "1b40729aa10a727150a6cc56e532c770f4baded83846fca8700efd908d0f4d0a"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "24.1.43"
|
||||||
synchronized:
|
synchronized:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ dependencies:
|
|||||||
envied: ^0.5.2
|
envied: ^0.5.2
|
||||||
cached_network_image: ^3.3.0
|
cached_network_image: ^3.3.0
|
||||||
calendar_builder: ^0.0.6
|
calendar_builder: ^0.0.6
|
||||||
fl_chart: ^0.65.0
|
syncfusion_flutter_charts: ^24.1.43
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user