|
|
|
@ -38,9 +38,7 @@ class LineChartCurvedState extends State<LineChartCurved> {
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return AspectRatio(
|
|
|
|
|
aspectRatio: 1.23,
|
|
|
|
|
child: Container(
|
|
|
|
|
return Container(
|
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(18)),
|
|
|
|
|
// color: Colors.white,
|
|
|
|
@ -48,37 +46,27 @@ class LineChartCurvedState extends State<LineChartCurved> {
|
|
|
|
|
child: Stack(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 4,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
widget.title,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: Colors.black,
|
|
|
|
|
fontSize: 32,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
letterSpacing: 2),
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
style: TextStyle(fontSize: 16, fontFamily: "Poppins", fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.64, height: 25 / 16),
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
SizedBox(height: 16),
|
|
|
|
|
AspectRatio(
|
|
|
|
|
aspectRatio: 333 / 288,
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.only(right: 16.0, left: 6.0),
|
|
|
|
|
padding: EdgeInsets.only(right: 16.0, left: 6.0),
|
|
|
|
|
child: LineChart(
|
|
|
|
|
sampleData1(),
|
|
|
|
|
swapAnimationDuration: const Duration(milliseconds: 250),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 10,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -91,17 +79,13 @@ class LineChartCurvedState extends State<LineChartCurved> {
|
|
|
|
|
touchCallback: (LineTouchResponse touchResponse) {},
|
|
|
|
|
handleBuiltInTouches: true,
|
|
|
|
|
),
|
|
|
|
|
gridData: FlGridData(
|
|
|
|
|
show: true, drawVerticalLine: true, drawHorizontalLine: true),
|
|
|
|
|
gridData: FlGridData(show: true, drawVerticalLine: false, drawHorizontalLine: true),
|
|
|
|
|
titlesData: FlTitlesData(
|
|
|
|
|
bottomTitles: SideTitles(
|
|
|
|
|
showTitles: true,
|
|
|
|
|
getTextStyles: (value) => const TextStyle(
|
|
|
|
|
color: Colors.black,
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
),
|
|
|
|
|
margin: 22,
|
|
|
|
|
rotateAngle:-65,
|
|
|
|
|
getTextStyles: (value) => TextStyle(fontSize: 12, fontFamily: "Poppins", fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: 0, height: 18 / 12),
|
|
|
|
|
margin: 8,
|
|
|
|
|
rotateAngle: -0,
|
|
|
|
|
getTitles: (value) {
|
|
|
|
|
print(value);
|
|
|
|
|
DateTime date = DateUtil.convertStringToDate(widget.labResult[value.toInt()].verifiedOnDateTime);
|
|
|
|
@ -111,27 +95,20 @@ class LineChartCurvedState extends State<LineChartCurved> {
|
|
|
|
|
} else
|
|
|
|
|
return '';
|
|
|
|
|
} else {
|
|
|
|
|
if (value.toInt() == 0)
|
|
|
|
|
return '${date.day}/ ${date.year}';
|
|
|
|
|
if (value.toInt() == widget.labResult.length - 1)
|
|
|
|
|
return '${date.day}/ ${date.year}';
|
|
|
|
|
if (value.toInt() == 0) return '${date.day}/ ${date.year}';
|
|
|
|
|
if (value.toInt() == widget.labResult.length - 1) return '${date.day}/ ${date.year}';
|
|
|
|
|
if (xAxixs.contains(value.toInt())) {
|
|
|
|
|
return '${date.day}/ ${date.year}';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return '';
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
leftTitles: SideTitles(
|
|
|
|
|
showTitles: true,
|
|
|
|
|
getTextStyles: (value) => const TextStyle(
|
|
|
|
|
color: Colors.black,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
),
|
|
|
|
|
getTextStyles: (value) => TextStyle(fontSize: 12, fontFamily: "Poppins", fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: 0, height: 18 / 12),
|
|
|
|
|
|
|
|
|
|
getTitles: (value) {
|
|
|
|
|
return '${value.toInt()}';
|
|
|
|
|
},
|
|
|
|
@ -140,22 +117,22 @@ class LineChartCurvedState extends State<LineChartCurved> {
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
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,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
show: false,
|
|
|
|
|
// 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: (widget.labResult.length - 1).toDouble(),
|
|
|
|
@ -168,10 +145,10 @@ class LineChartCurvedState extends State<LineChartCurved> {
|
|
|
|
|
double getMaxY() {
|
|
|
|
|
double max = 0;
|
|
|
|
|
widget.labResult.forEach((element) {
|
|
|
|
|
try{
|
|
|
|
|
try {
|
|
|
|
|
double resultValueDouble = double.parse(element.resultValue);
|
|
|
|
|
if (resultValueDouble > max) max = resultValueDouble;}
|
|
|
|
|
catch(e){
|
|
|
|
|
if (resultValueDouble > max) max = resultValueDouble;
|
|
|
|
|
} catch (e) {
|
|
|
|
|
print(e);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
@ -181,13 +158,14 @@ class LineChartCurvedState extends State<LineChartCurved> {
|
|
|
|
|
|
|
|
|
|
double getMinY() {
|
|
|
|
|
double min = 0;
|
|
|
|
|
try{
|
|
|
|
|
try {
|
|
|
|
|
min = double.parse(widget.labResult[0].resultValue);
|
|
|
|
|
|
|
|
|
|
widget.labResult.forEach((element) {
|
|
|
|
|
double resultValueDouble = double.parse(element.resultValue);
|
|
|
|
|
if (resultValueDouble < min) min = resultValueDouble;
|
|
|
|
|
});}catch(e){
|
|
|
|
|
});
|
|
|
|
|
} catch (e) {
|
|
|
|
|
print(e);
|
|
|
|
|
}
|
|
|
|
|
int value = min.toInt();
|
|
|
|
@ -198,21 +176,22 @@ class LineChartCurvedState extends State<LineChartCurved> {
|
|
|
|
|
List<LineChartBarData> getData() {
|
|
|
|
|
List<FlSpot> spots = List();
|
|
|
|
|
for (int index = 0; index < widget.labResult.length; index++) {
|
|
|
|
|
try{
|
|
|
|
|
try {
|
|
|
|
|
var resultValueDouble = double.parse(widget.labResult[index].resultValue);
|
|
|
|
|
print("$index:$resultValueDouble");
|
|
|
|
|
spots.add(FlSpot(index.toDouble(), resultValueDouble));
|
|
|
|
|
}catch(e){
|
|
|
|
|
} catch (e) {
|
|
|
|
|
print(e);
|
|
|
|
|
spots.add(FlSpot(index.toDouble(), 0.0));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final LineChartBarData lineChartBarData1 = LineChartBarData(
|
|
|
|
|
spots: spots,
|
|
|
|
|
isCurved: true,
|
|
|
|
|
colors: [Theme.of(context).primaryColor],
|
|
|
|
|
barWidth: 5,
|
|
|
|
|
//preventCurveOverShooting : true,
|
|
|
|
|
colors: [Color(0xffD02127)],
|
|
|
|
|
barWidth: 1.5,
|
|
|
|
|
isStrokeCapRound: true,
|
|
|
|
|
dotData: FlDotData(
|
|
|
|
|
show: false,
|
|
|
|
|