|
|
|
@ -1,3 +1,4 @@
|
|
|
|
|
|
|
|
import 'package:date_time_picker/date_time_picker.dart';
|
|
|
|
import 'package:doctor_app_flutter/config/size_config.dart';
|
|
|
|
import 'package:doctor_app_flutter/config/size_config.dart';
|
|
|
|
import 'package:doctor_app_flutter/widgets/charts/app_time_series_chart.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:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
|
|
|
|
@ -14,6 +15,11 @@ class LineChartCurved extends StatelessWidget {
|
|
|
|
List<int> xAxixs = List();
|
|
|
|
List<int> xAxixs = List();
|
|
|
|
List<double> yAxixs = List();
|
|
|
|
List<double> yAxixs = List();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// DateFormat format = DateFormat("yyyy-MM-dd");
|
|
|
|
|
|
|
|
DateFormat yearFormat = DateFormat("yyyy/MMM");
|
|
|
|
|
|
|
|
DateFormat monthFormat = DateFormat("MMM");
|
|
|
|
|
|
|
|
bool isDatesSameYear = true;
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
getXaxix();
|
|
|
|
getXaxix();
|
|
|
|
@ -38,7 +44,7 @@ class LineChartCurved extends StatelessWidget {
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
AppText(
|
|
|
|
AppText(
|
|
|
|
title,
|
|
|
|
title,
|
|
|
|
fontSize: SizeConfig.textMultiplier * 2.5,
|
|
|
|
fontSize: SizeConfig.textMultiplier * 2.1,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
backGroundcolor: Colors.black,
|
|
|
|
backGroundcolor: Colors.black,
|
|
|
|
fontFamily: 'Poppins',
|
|
|
|
fontFamily: 'Poppins',
|
|
|
|
@ -47,7 +53,9 @@ class LineChartCurved extends StatelessWidget {
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SizedBox(height: 16,),
|
|
|
|
SizedBox(
|
|
|
|
|
|
|
|
height: 16,
|
|
|
|
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
Expanded(
|
|
|
|
child: Padding(
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.only(right: 18.0, left: 16.0),
|
|
|
|
padding: const EdgeInsets.only(right: 18.0, left: 16.0),
|
|
|
|
@ -74,8 +82,9 @@ class LineChartCurved extends StatelessWidget {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getYaxix() {
|
|
|
|
getYaxix() {
|
|
|
|
int indexess= (timeSeries.length*0.30).toInt();
|
|
|
|
int indexess = (timeSeries.length * 0.30).toInt();
|
|
|
|
for (int index = 0; index < timeSeries.length; index++) {
|
|
|
|
for (int index = 0; index < timeSeries.length; index++) {
|
|
|
|
int mIndex = indexess * index;
|
|
|
|
int mIndex = indexess * index;
|
|
|
|
if (mIndex < timeSeries.length) {
|
|
|
|
if (mIndex < timeSeries.length) {
|
|
|
|
@ -89,7 +98,6 @@ class LineChartCurved extends StatelessWidget {
|
|
|
|
lineTouchData: LineTouchData(
|
|
|
|
lineTouchData: LineTouchData(
|
|
|
|
touchTooltipData: LineTouchTooltipData(
|
|
|
|
touchTooltipData: LineTouchTooltipData(
|
|
|
|
tooltipBgColor: Colors.white,
|
|
|
|
tooltipBgColor: Colors.white,
|
|
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
touchCallback: (LineTouchResponse touchResponse) {},
|
|
|
|
touchCallback: (LineTouchResponse touchResponse) {},
|
|
|
|
handleBuiltInTouches: true,
|
|
|
|
handleBuiltInTouches: true,
|
|
|
|
@ -103,12 +111,23 @@ class LineChartCurved extends StatelessWidget {
|
|
|
|
color: Colors.black,
|
|
|
|
color: Colors.black,
|
|
|
|
fontSize: 10,
|
|
|
|
fontSize: 10,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
rotateAngle:-65,
|
|
|
|
rotateAngle: -65,
|
|
|
|
//rotateAngle:-65,
|
|
|
|
//rotateAngle:-65,
|
|
|
|
margin: 22,
|
|
|
|
margin: 22,
|
|
|
|
getTitles: (value) {
|
|
|
|
getTitles: (value) {
|
|
|
|
if (timeSeries.length < 15) {
|
|
|
|
|
|
|
|
if (timeSeries.length > value.toInt()) {
|
|
|
|
if (timeSeries.length > value.toInt()) {
|
|
|
|
|
|
|
|
DateTime dateTime = timeSeries[value.toInt()].time;
|
|
|
|
|
|
|
|
if (isDatesSameYear) {
|
|
|
|
|
|
|
|
return monthFormat.format(dateTime);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return yearFormat.format(dateTime);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return '';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*if (timeSeries.length < 15) {
|
|
|
|
|
|
|
|
if (timeSeries.length > value.toInt()) {
|
|
|
|
|
|
|
|
DateTime dateTime = timeSeries[value.toInt()].time;
|
|
|
|
return '${timeSeries[value.toInt()].time.month}/ ${timeSeries[value.toInt()].time.year}';
|
|
|
|
return '${timeSeries[value.toInt()].time.month}/ ${timeSeries[value.toInt()].time.year}';
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|
return '';
|
|
|
|
return '';
|
|
|
|
@ -120,7 +139,7 @@ class LineChartCurved extends StatelessWidget {
|
|
|
|
if (xAxixs.contains(value.toInt())) {
|
|
|
|
if (xAxixs.contains(value.toInt())) {
|
|
|
|
return '${timeSeries[value.toInt()].time.month}/ ${timeSeries[value.toInt()].time.year}';
|
|
|
|
return '${timeSeries[value.toInt()].time.month}/ ${timeSeries[value.toInt()].time.year}';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}*/
|
|
|
|
return '';
|
|
|
|
return '';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
@ -169,7 +188,7 @@ class LineChartCurved extends StatelessWidget {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
minX: 0,
|
|
|
|
minX: 0,
|
|
|
|
maxX: (timeSeries.length - 1).toDouble(),
|
|
|
|
maxX: (timeSeries.length - 1).toDouble(),
|
|
|
|
maxY: getMaxY()+0.3,
|
|
|
|
maxY: getMaxY() + 0.3,
|
|
|
|
minY: getMinY(),
|
|
|
|
minY: getMinY(),
|
|
|
|
lineBarsData: getData(context),
|
|
|
|
lineBarsData: getData(context),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
@ -182,7 +201,7 @@ class LineChartCurved extends StatelessWidget {
|
|
|
|
if (resultValueDouble > max) max = resultValueDouble;
|
|
|
|
if (resultValueDouble > max) max = resultValueDouble;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return max.roundToDouble() ;
|
|
|
|
return max.roundToDouble();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
double getMinY() {
|
|
|
|
double getMinY() {
|
|
|
|
@ -198,14 +217,22 @@ class LineChartCurved extends StatelessWidget {
|
|
|
|
|
|
|
|
|
|
|
|
List<LineChartBarData> getData(context) {
|
|
|
|
List<LineChartBarData> getData(context) {
|
|
|
|
List<FlSpot> spots = List();
|
|
|
|
List<FlSpot> spots = List();
|
|
|
|
|
|
|
|
isDatesSameYear = true;
|
|
|
|
|
|
|
|
int previousDateYear = 0;
|
|
|
|
for (int index = 0; index < timeSeries.length; index++) {
|
|
|
|
for (int index = 0; index < timeSeries.length; index++) {
|
|
|
|
spots.add(FlSpot(index.toDouble(), timeSeries[index].sales));
|
|
|
|
spots.add(FlSpot(index.toDouble(), timeSeries[index].sales));
|
|
|
|
|
|
|
|
if (isDatesSameYear == false ||
|
|
|
|
|
|
|
|
(previousDateYear != 0 &&
|
|
|
|
|
|
|
|
previousDateYear != timeSeries[index].time.year)) {
|
|
|
|
|
|
|
|
isDatesSameYear = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
previousDateYear = timeSeries[index].time.year;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
final LineChartBarData lineChartBarData1 = LineChartBarData(
|
|
|
|
final LineChartBarData lineChartBarData1 = LineChartBarData(
|
|
|
|
spots: spots,
|
|
|
|
spots: spots,
|
|
|
|
isCurved: true,
|
|
|
|
isCurved: true,
|
|
|
|
colors: [Theme.of(context).primaryColor],
|
|
|
|
colors: [Colors.red]/*[Theme.of(context).primaryColor]*/,
|
|
|
|
barWidth: 5,
|
|
|
|
barWidth: 5,
|
|
|
|
isStrokeCapRound: true,
|
|
|
|
isStrokeCapRound: true,
|
|
|
|
dotData: FlDotData(
|
|
|
|
dotData: FlDotData(
|
|
|
|
|