first step from get diabetic
parent
45f4aa9a22
commit
dd971ffddb
@ -0,0 +1,44 @@
|
|||||||
|
class GetDiabeticChartValuesRequestModel {
|
||||||
|
int deviceTypeID;
|
||||||
|
int patientID;
|
||||||
|
int resultType;
|
||||||
|
int admissionNo;
|
||||||
|
String setupID;
|
||||||
|
bool patientOutSA;
|
||||||
|
int patientType;
|
||||||
|
int patientTypeID;
|
||||||
|
|
||||||
|
GetDiabeticChartValuesRequestModel(
|
||||||
|
{this.deviceTypeID,
|
||||||
|
this.patientID,
|
||||||
|
this.resultType,
|
||||||
|
this.admissionNo,
|
||||||
|
this.setupID,
|
||||||
|
this.patientOutSA,
|
||||||
|
this.patientType,
|
||||||
|
this.patientTypeID});
|
||||||
|
|
||||||
|
GetDiabeticChartValuesRequestModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
deviceTypeID = json['DeviceTypeID'];
|
||||||
|
patientID = json['PatientID'];
|
||||||
|
resultType = json['ResultType'];
|
||||||
|
admissionNo = json['AdmissionNo'];
|
||||||
|
setupID = json['SetupID'];
|
||||||
|
patientOutSA = json['PatientOutSA'];
|
||||||
|
patientType = json['PatientType'];
|
||||||
|
patientTypeID = json['PatientTypeID'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['DeviceTypeID'] = this.deviceTypeID;
|
||||||
|
data['PatientID'] = this.patientID;
|
||||||
|
data['ResultType'] = this.resultType;
|
||||||
|
data['AdmissionNo'] = this.admissionNo;
|
||||||
|
data['SetupID'] = this.setupID;
|
||||||
|
data['PatientOutSA'] = this.patientOutSA;
|
||||||
|
data['PatientType'] = this.patientType;
|
||||||
|
data['PatientTypeID'] = this.patientTypeID;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
class GetDiabeticChartValuesResponseModel {
|
||||||
|
String resultType;
|
||||||
|
int admissionNo;
|
||||||
|
String dateChart;
|
||||||
|
int resultValue;
|
||||||
|
int createdBy;
|
||||||
|
String createdOn;
|
||||||
|
|
||||||
|
GetDiabeticChartValuesResponseModel(
|
||||||
|
{this.resultType,
|
||||||
|
this.admissionNo,
|
||||||
|
this.dateChart,
|
||||||
|
this.resultValue,
|
||||||
|
this.createdBy,
|
||||||
|
this.createdOn});
|
||||||
|
|
||||||
|
GetDiabeticChartValuesResponseModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
resultType = json['ResultType'];
|
||||||
|
admissionNo = json['AdmissionNo'];
|
||||||
|
dateChart = json['DateChart'];
|
||||||
|
resultValue = json['ResultValue'];
|
||||||
|
createdBy = json['CreatedBy'];
|
||||||
|
createdOn = json['CreatedOn'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['ResultType'] = this.resultType;
|
||||||
|
data['AdmissionNo'] = this.admissionNo;
|
||||||
|
data['DateChart'] = this.dateChart;
|
||||||
|
data['ResultValue'] = this.resultValue;
|
||||||
|
data['CreatedBy'] = this.createdBy;
|
||||||
|
data['CreatedOn'] = this.createdOn;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,134 @@
|
|||||||
|
import 'package:doctor_app_flutter/config/size_config.dart';
|
||||||
|
import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart';
|
||||||
|
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
|
||||||
|
import 'package:doctor_app_flutter/models/patient/vital_sign/patient-vital-sign-history.dart';
|
||||||
|
import 'package:doctor_app_flutter/screens/base/base_view.dart';
|
||||||
|
import 'package:doctor_app_flutter/screens/patients/profile/diabetic_chart/line_chart_for_diabetic.dart';
|
||||||
|
import 'package:doctor_app_flutter/screens/patients/profile/vital_sign/vital_sign_details_blood_pressurewideget.dart';
|
||||||
|
import 'package:doctor_app_flutter/util/date-utils.dart';
|
||||||
|
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
|
||||||
|
import 'package:doctor_app_flutter/widgets/charts/app_time_series_chart.dart';
|
||||||
|
import 'package:doctor_app_flutter/widgets/patients/profile/patient-profile-app-bar.dart';
|
||||||
|
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
|
||||||
|
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
|
||||||
|
import 'package:doctor_app_flutter/widgets/shared/card_with_bg_widget.dart';
|
||||||
|
import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'diabetic_details_blood_pressurewideget.dart';
|
||||||
|
|
||||||
|
class DiabeticChart extends StatelessWidget {
|
||||||
|
DiabeticChart({
|
||||||
|
Key key,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
List<TimeSeriesSales2> timeSeriesData1 = [];
|
||||||
|
List<TimeSeriesSales2> timeSeriesData2 = [];
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final routeArgs = ModalRoute.of(context).settings.arguments as Map;
|
||||||
|
PatiantInformtion patient = routeArgs['patient'];
|
||||||
|
|
||||||
|
return BaseView<PatientViewModel>(
|
||||||
|
onModelReady: (model) async {
|
||||||
|
await model.getDiabeticChartValues(patient, 3);
|
||||||
|
generateData(model);
|
||||||
|
},
|
||||||
|
builder: (_, model, w) => AppScaffold(
|
||||||
|
baseViewModel: model,
|
||||||
|
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
|
appBar: PatientProfileAppBar(
|
||||||
|
patient,
|
||||||
|
isInpatient: true,
|
||||||
|
),
|
||||||
|
body: SingleChildScrollView(
|
||||||
|
child: Column(children: [
|
||||||
|
timeSeriesData1.length != 0 || timeSeriesData2.length != 0
|
||||||
|
? Padding(
|
||||||
|
padding: const EdgeInsets.all(10.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
Container(
|
||||||
|
margin: EdgeInsets.symmetric(horizontal: 8),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(12)),
|
||||||
|
child: LineChartForDiabetic(
|
||||||
|
title: "Blood Glucose",
|
||||||
|
isOX: false,
|
||||||
|
timeSeries1: timeSeriesData1,
|
||||||
|
// timeSeries2: timeSeriesData2,
|
||||||
|
indexes: timeSeriesData1.length ~/ 5.5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
margin: EdgeInsets.symmetric(horizontal: 8, vertical: 16),
|
||||||
|
padding:
|
||||||
|
EdgeInsets.only(top: 16, right: 18.0, left: 16.0),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(12)),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
AppText(
|
||||||
|
TranslationBase.of(context).graphDetails,
|
||||||
|
fontSize: SizeConfig.textMultiplier * 2.3,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontFamily: 'Poppins',
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 8,
|
||||||
|
),
|
||||||
|
DiabeticDetails(
|
||||||
|
diabeticDetailsList: model.diabeticChartValuesList,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Container(
|
||||||
|
width: double.infinity,
|
||||||
|
height: MediaQuery.of(context).size.height,
|
||||||
|
child: Center(
|
||||||
|
child:
|
||||||
|
AppText(TranslationBase.of(context).vitalSignDetailEmpty),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
generateData(PatientViewModel model) {
|
||||||
|
if (model.diabeticChartValuesList.length > 0) {
|
||||||
|
model.diabeticChartValuesList.toList().forEach(
|
||||||
|
(element) {
|
||||||
|
DateTime elementDate =
|
||||||
|
AppDateUtils.getDateTimeFromServerFormat(element.dateChart);
|
||||||
|
if (element.resultValue.toInt() != 0)
|
||||||
|
timeSeriesData1.add(
|
||||||
|
TimeSeriesSales2(
|
||||||
|
new DateTime(
|
||||||
|
elementDate.year, elementDate.month, elementDate.day),
|
||||||
|
element.resultValue.toDouble(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (element.resultValue.toInt() != 0)
|
||||||
|
timeSeriesData2.add(
|
||||||
|
TimeSeriesSales2(
|
||||||
|
new DateTime(
|
||||||
|
elementDate.year, elementDate.month, elementDate.day),
|
||||||
|
element.resultValue.toDouble(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,123 @@
|
|||||||
|
import 'package:doctor_app_flutter/config/size_config.dart';
|
||||||
|
import 'package:doctor_app_flutter/core/model/diabetic_chart/GetDiabeticChartValuesResponseModel.dart';
|
||||||
|
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
|
||||||
|
import 'package:doctor_app_flutter/models/patient/vital_sign/patient-vital-sign-history.dart';
|
||||||
|
import 'package:doctor_app_flutter/util/date-utils.dart';
|
||||||
|
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
|
||||||
|
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class DiabeticDetails extends StatefulWidget {
|
||||||
|
final List<GetDiabeticChartValuesResponseModel> diabeticDetailsList;
|
||||||
|
|
||||||
|
DiabeticDetails(
|
||||||
|
{Key key, this.diabeticDetailsList,});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_VitalSignDetailsWidgetState createState() => _VitalSignDetailsWidgetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _VitalSignDetailsWidgetState extends State<DiabeticDetails> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
ProjectViewModel projectViewModel = Provider.of(context);
|
||||||
|
return Container(
|
||||||
|
margin: EdgeInsets.all(0),
|
||||||
|
child: Container(
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Container(
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.all(8),
|
||||||
|
child: AppText(
|
||||||
|
TranslationBase.of(context).date,
|
||||||
|
fontSize: SizeConfig.textMultiplier * 1.5,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
|
||||||
|
fontFamily: 'Poppins',
|
||||||
|
),
|
||||||
|
// height: 60,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.all(8),
|
||||||
|
child: Container(
|
||||||
|
child: AppText(
|
||||||
|
"Result",
|
||||||
|
fontSize: SizeConfig.textMultiplier * 1.5,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontFamily: 'Poppins',
|
||||||
|
),
|
||||||
|
// height: 60
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const Divider(
|
||||||
|
height: 1,
|
||||||
|
thickness: 1,
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
Table(
|
||||||
|
border: TableBorder(
|
||||||
|
horizontalInside: BorderSide(width: 1.0, color: Colors.grey[300]),
|
||||||
|
),
|
||||||
|
children: fullData(projectViewModel),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<TableRow> fullData(ProjectViewModel projectViewModel) {
|
||||||
|
List<TableRow> tableRow = [];
|
||||||
|
widget.diabeticDetailsList.forEach((diabetic) {
|
||||||
|
var data = diabetic.resultValue;
|
||||||
|
DateTime elementDate =
|
||||||
|
AppDateUtils.getDateTimeFromServerFormat(diabetic.dateChart);
|
||||||
|
if (data != 0)
|
||||||
|
tableRow.add(TableRow(children: [
|
||||||
|
Container(
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.all(10),
|
||||||
|
color: Colors.white,
|
||||||
|
child: AppText(
|
||||||
|
'${projectViewModel.isArabic ? AppDateUtils.getWeekDayArabic(elementDate.weekday) : AppDateUtils.getWeekDay(elementDate.weekday)}, ${elementDate.day} ${projectViewModel.isArabic ? AppDateUtils.getMonthArabic(elementDate.month) : AppDateUtils.getMonth(elementDate.month)}, ${elementDate.year} ${AppDateUtils.getHour(elementDate)}',
|
||||||
|
// textAlign: TextAlign.center,
|
||||||
|
fontSize: SizeConfig.textMultiplier * 1.6,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
|
||||||
|
fontFamily: 'Poppins',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.all(10),
|
||||||
|
color: Colors.white,
|
||||||
|
child: AppText(
|
||||||
|
'${diabetic.resultValue}',
|
||||||
|
// textAlign: TextAlign.center,
|
||||||
|
fontSize: SizeConfig.textMultiplier * 1.6,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
|
||||||
|
fontFamily: 'Poppins',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
return tableRow;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,237 @@
|
|||||||
|
import 'package:doctor_app_flutter/config/size_config.dart';
|
||||||
|
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
|
||||||
|
import 'package:doctor_app_flutter/widgets/charts/app_time_series_chart.dart';
|
||||||
|
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
|
||||||
|
import 'package:fl_chart/fl_chart.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class LineChartForDiabetic extends StatelessWidget {
|
||||||
|
final String title;
|
||||||
|
final List<TimeSeriesSales2> timeSeries1;
|
||||||
|
final int indexes;
|
||||||
|
final bool isOX;
|
||||||
|
|
||||||
|
LineChartForDiabetic(
|
||||||
|
{this.title, this.timeSeries1, this.indexes, this.isOX= false});
|
||||||
|
|
||||||
|
List<int> xAxixs = List();
|
||||||
|
List<double> yAxixs = List();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
getXaxix();
|
||||||
|
return AspectRatio(
|
||||||
|
aspectRatio: 1.1,
|
||||||
|
child: Container(
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(18)),
|
||||||
|
// color: Colors.white,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: <Widget>[
|
||||||
|
const SizedBox(
|
||||||
|
height: 4,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.only(right: 18.0, left: 16.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
AppText(
|
||||||
|
title,
|
||||||
|
fontSize: SizeConfig.textMultiplier * 2.1,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontFamily: 'Poppins',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Padding(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.only(right: 18.0, left: 16.0, top: 15),
|
||||||
|
child: LineChart(
|
||||||
|
sampleData1(context),
|
||||||
|
swapAnimationDuration: const Duration(milliseconds: 250),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
getXaxix() {
|
||||||
|
for (int index = 0; index < timeSeries1.length; index++) {
|
||||||
|
int mIndex = indexes * index;
|
||||||
|
if (mIndex < timeSeries1.length) {
|
||||||
|
xAxixs.add(mIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LineChartData sampleData1(context) {
|
||||||
|
return LineChartData(
|
||||||
|
lineTouchData: LineTouchData(
|
||||||
|
touchTooltipData: LineTouchTooltipData(
|
||||||
|
tooltipBgColor: Colors.white,
|
||||||
|
),
|
||||||
|
touchCallback: (LineTouchResponse touchResponse) {},
|
||||||
|
handleBuiltInTouches: true,
|
||||||
|
),
|
||||||
|
gridData: FlGridData(
|
||||||
|
show: true, drawVerticalLine: true, drawHorizontalLine: true),
|
||||||
|
titlesData: FlTitlesData(
|
||||||
|
bottomTitles: SideTitles(
|
||||||
|
showTitles: true,
|
||||||
|
getTextStyles: (value) => const TextStyle(
|
||||||
|
color: Colors.black,
|
||||||
|
fontSize: 10,
|
||||||
|
),
|
||||||
|
rotateAngle: -65,
|
||||||
|
//rotateAngle:-65,
|
||||||
|
interval: 100,
|
||||||
|
margin: 22,
|
||||||
|
getTitles: (value) {
|
||||||
|
if (timeSeries1.length < 15) {
|
||||||
|
if (timeSeries1.length > value.toInt()) {
|
||||||
|
return '${timeSeries1[value.toInt()].time.month}/ ${timeSeries1[value.toInt()].time.year}';
|
||||||
|
} else
|
||||||
|
return '';
|
||||||
|
} else {
|
||||||
|
if (value.toInt() == 0)
|
||||||
|
return '${timeSeries1[value.toInt()].time.month}/ ${timeSeries1[value.toInt()].time.year}';
|
||||||
|
if (value.toInt() == timeSeries1.length - 1)
|
||||||
|
return '${timeSeries1[value.toInt()].time.month}/ ${timeSeries1[value.toInt()].time.year}';
|
||||||
|
if (xAxixs.contains(value.toInt())) {
|
||||||
|
return '${timeSeries1[value.toInt()].time.month}/ ${timeSeries1[value.toInt()].time.year}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
),
|
||||||
|
leftTitles: SideTitles(
|
||||||
|
showTitles: true,
|
||||||
|
getTextStyles: (value) => const TextStyle(
|
||||||
|
color: Colors.black,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 10,
|
||||||
|
),
|
||||||
|
interval:getMaxY() - getMinY() <=500?50:getMaxY() - getMinY() <=1000?100:200,
|
||||||
|
|
||||||
|
margin: 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
borderData: FlBorderData(
|
||||||
|
show: true,
|
||||||
|
border: const Border(
|
||||||
|
bottom: BorderSide(
|
||||||
|
color: Colors.black,
|
||||||
|
width: 0.5,
|
||||||
|
),
|
||||||
|
left: BorderSide(
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
right: BorderSide(
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
top: BorderSide(
|
||||||
|
color: Colors.transparent,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
minX: 0,
|
||||||
|
maxX: (timeSeries1.length - 1).toDouble(),
|
||||||
|
maxY: getMaxY() + 0.3,
|
||||||
|
minY: getMinY(),
|
||||||
|
lineBarsData: getData(context),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
double getMaxY() {
|
||||||
|
double max = 0;
|
||||||
|
timeSeries1.forEach((element) {
|
||||||
|
double resultValueDouble = element.sales;
|
||||||
|
if (resultValueDouble > max) max = resultValueDouble;
|
||||||
|
});
|
||||||
|
// timeSeries2.forEach((element) {
|
||||||
|
// double resultValueDouble = element.sales;
|
||||||
|
// if (resultValueDouble > max) max = resultValueDouble;
|
||||||
|
// });
|
||||||
|
|
||||||
|
return max.roundToDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
double getMinY() {
|
||||||
|
double min = timeSeries1[0].sales;
|
||||||
|
timeSeries1.forEach((element) {
|
||||||
|
double resultValueDouble = element.sales;
|
||||||
|
if (resultValueDouble < min) min = resultValueDouble;
|
||||||
|
});
|
||||||
|
// timeSeries2.forEach((element) {
|
||||||
|
// double resultValueDouble = element.sales;
|
||||||
|
// if (resultValueDouble < min) min = resultValueDouble;
|
||||||
|
// });
|
||||||
|
|
||||||
|
int value = min.toInt();
|
||||||
|
|
||||||
|
return value.toDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<LineChartBarData> getData(context) {
|
||||||
|
List<FlSpot> spots = List();
|
||||||
|
for (int index = 0; index < timeSeries1.length; index++) {
|
||||||
|
spots.add(FlSpot(index.toDouble(), timeSeries1[index].sales));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<FlSpot> spots2 = List();
|
||||||
|
// for (int index = 0; index < timeSeries2.length; index++) {
|
||||||
|
// spots2.add(FlSpot(index.toDouble(), timeSeries2[index].sales));
|
||||||
|
// }
|
||||||
|
|
||||||
|
final LineChartBarData lineChartBarData1 = LineChartBarData(
|
||||||
|
spots: spots,
|
||||||
|
isCurved: true,
|
||||||
|
colors: [Colors.red],
|
||||||
|
barWidth: 5,
|
||||||
|
isStrokeCapRound: true,
|
||||||
|
dotData: FlDotData(
|
||||||
|
show: false,
|
||||||
|
),
|
||||||
|
belowBarData: BarAreaData(
|
||||||
|
show: false,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final LineChartBarData lineChartBarData2 = LineChartBarData(
|
||||||
|
spots: spots2,
|
||||||
|
isCurved: true,
|
||||||
|
colors: [Colors.red],
|
||||||
|
barWidth: 5,
|
||||||
|
isStrokeCapRound: true,
|
||||||
|
dotData: FlDotData(
|
||||||
|
show: false,
|
||||||
|
),
|
||||||
|
belowBarData: BarAreaData(
|
||||||
|
show: false,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
List<LineChartBarData> lineChartData = List();
|
||||||
|
if(spots.isNotEmpty){
|
||||||
|
lineChartData.add(lineChartBarData1);
|
||||||
|
}
|
||||||
|
if(spots2.isNotEmpty){
|
||||||
|
lineChartData.add(lineChartBarData2);
|
||||||
|
}
|
||||||
|
return lineChartData;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue