Revert "graph values fix and comparision with the pdf"

This reverts commit fc21746683.
dev_aamir
tahaalam 1 day ago
parent fc21746683
commit 4dce062daf

@ -377,8 +377,7 @@ class LabViewModel extends ChangeNotifier {
LoaderBottomSheet.hideLoader(); LoaderBottomSheet.hideLoader();
if (apiResponse.messageStatus == 2) { if (apiResponse.messageStatus == 2) {
} else if (apiResponse.messageStatus == 1) { } else if (apiResponse.messageStatus == 1) {
var sortedResult = sort(apiResponse.data!); var recentThree = sort(apiResponse.data!);
var recentThree = sortedResult.take(3).toList();
mainLabResults = recentThree; mainLabResults = recentThree;
double highRefrenceValue = double.negativeInfinity; double highRefrenceValue = double.negativeInfinity;
@ -386,12 +385,11 @@ class LabViewModel extends ChangeNotifier {
double lowRefenceValue = double.infinity; double lowRefenceValue = double.infinity;
String? flagForLowReferenceRange; String? flagForLowReferenceRange;
sortedResult.take(3).toList().reversed.forEach((element) { recentThree.reversed.forEach((element) {
try { try {
var dateTime = DateUtil.convertStringToDate(element.verifiedOnDateTime!); var dateTime = DateUtil.convertStringToDate(element.verifiedOnDateTime!);
var resultValue = double.parse(element.resultValue!); var resultValue = double.parse(element.resultValue!);
// var transformedValue = transformValueInRange(double.parse(element.resultValue!), element.calculatedResultFlag ?? ""); var transformedValue = transformValueInRange(double.parse(element.resultValue!), element.calculatedResultFlag ?? "");
var transformedValue = resultValue;
if (resultValue > maxY) { if (resultValue > maxY) {
maxY = resultValue; maxY = resultValue;
maxX = maxY; maxX = maxY;
@ -423,9 +421,9 @@ class LabViewModel extends ChangeNotifier {
highRefrenceValue = maxY; highRefrenceValue = maxY;
lowRefenceValue = minY; lowRefenceValue = minY;
} }
//
if (minY > lowRefenceValue) { if (minY > lowRefenceValue) {
minY = lowRefenceValue - getInterval(); minY = lowRefenceValue - 25;
} }
this.flagForHighReferenceRange = flagForHighReferenceRange; this.flagForHighReferenceRange = flagForHighReferenceRange;
@ -434,16 +432,12 @@ class LabViewModel extends ChangeNotifier {
lowTransformedReferenceValue = double.parse(transformValueInRange(lowRefenceValue, flagForLowReferenceRange ?? "").toStringAsFixed(1)); lowTransformedReferenceValue = double.parse(transformValueInRange(lowRefenceValue, flagForLowReferenceRange ?? "").toStringAsFixed(1));
this.highRefrenceValue = double.parse(highRefrenceValue.toStringAsFixed(1)); this.highRefrenceValue = double.parse(highRefrenceValue.toStringAsFixed(1));
this.lowRefenceValue = double.parse(lowRefenceValue.toStringAsFixed(1)); this.lowRefenceValue = double.parse(lowRefenceValue.toStringAsFixed(1));
if(maxY<highRefrenceValue){
maxY = highRefrenceValue;
maxX = maxY; if (maxY < highRefrenceValue) {
maxY = highRefrenceValue;
} }
// if (maxY < highRefrenceValue) { maxY += 25;
// minY = highRefrenceValue - getInterval(); minY -= 25;
// }
// maxY += 25;
// minY -= 25;
LabResult recentResult = recentThree.first; LabResult recentResult = recentThree.first;
recentResult.uOM = unitOfMeasure; recentResult.uOM = unitOfMeasure;
checkIfGraphShouldBeDisplayed(recentResult); checkIfGraphShouldBeDisplayed(recentResult);
@ -460,17 +454,6 @@ class LabViewModel extends ChangeNotifier {
}, },
); );
} }
num getInterval() {
// return .1;
var maxX = maxY;
if(maxX<1) return .2;
if(maxX >=1.0 && maxX < 5.0) return .3;
if(maxX >=5.0 && maxX < 10.0) return 1.5;
if(maxX >=10.0 && maxX < 50.0) return 2.5;
if(maxX >=50.0 && maxX < 100.0) return 5;
if(maxX >=100.0 && maxX < 200.0) return 10;
return 15;
}
void checkIfGraphShouldBeDisplayed(LabResult recentResult) { void checkIfGraphShouldBeDisplayed(LabResult recentResult) {
shouldShowGraph = recentResult.checkIfGraphShouldBeDisplayed(); shouldShowGraph = recentResult.checkIfGraphShouldBeDisplayed();
@ -593,8 +576,7 @@ class LabViewModel extends ChangeNotifier {
try { try {
var dateTime = DateUtil.convertStringToDate(element.verifiedOnDateTime!); var dateTime = DateUtil.convertStringToDate(element.verifiedOnDateTime!);
var resultValue = double.parse(element.resultValue!); var resultValue = double.parse(element.resultValue!);
// var transformedValue = transformValueInRange(double.parse(element.resultValue!), element.calculatedResultFlag ?? ""); var transformedValue = transformValueInRange(double.parse(element.resultValue!), element.calculatedResultFlag ?? "");
var transformedValue = double.parse(element.resultValue!);
if (resultValue > maxY) { if (resultValue > maxY) {
maxY = resultValue; maxY = resultValue;
} }

@ -326,20 +326,20 @@ class LabResultDetails extends StatelessWidget {
}, },
leftLabelFormatter: (value) { leftLabelFormatter: (value) {
value = double.parse(value.toStringAsFixed(1)); value = double.parse(value.toStringAsFixed(1));
return leftLabels(value.toStringAsFixed(2)); // return leftLabels(value.toStringAsFixed(2));
// if (value == labmodel.highRefrenceValue) { if (value == labmodel.highRefrenceValue) {
// return leftLabels(LocaleKeys.high.tr()); return leftLabels(LocaleKeys.high.tr());
// } }
//
// if (value == labmodel.lowRefenceValue) { if (value == labmodel.lowRefenceValue) {
// return leftLabels(LocaleKeys.low.tr()); return leftLabels(LocaleKeys.low.tr());
// } }
return SizedBox.shrink(); return SizedBox.shrink();
// } // }
}, },
graphColor: AppColors.graphGridColor, graphColor: AppColors.blackColor,
graphShadowColor: AppColors.graphGridColor.withOpacity(.5), graphShadowColor: Colors.transparent,
graphGridColor: graphColor.withOpacity(.4), graphGridColor: graphColor.withOpacity(.4),
bottomLabelFormatter: (value, data) { bottomLabelFormatter: (value, data) {
if (data.isEmpty) return SizedBox.shrink(); if (data.isEmpty) return SizedBox.shrink();
@ -371,7 +371,7 @@ class LabResultDetails extends StatelessWidget {
ranges.add(HorizontalRangeAnnotation( ranges.add(HorizontalRangeAnnotation(
y1: model.minY, y1: model.minY,
y2: model.lowRefenceValue, y2: model.lowRefenceValue,
color: Colors.transparent, color: AppColors.highAndLow.withOpacity(0.05),
)); ));
ranges.add(HorizontalRangeAnnotation( ranges.add(HorizontalRangeAnnotation(
@ -383,7 +383,7 @@ class LabResultDetails extends StatelessWidget {
ranges.add(HorizontalRangeAnnotation( ranges.add(HorizontalRangeAnnotation(
y1: model.highRefrenceValue, y1: model.highRefrenceValue,
y2: model.maxY, y2: model.maxY,
color: Colors.transparent, color: AppColors.criticalLowAndHigh.withOpacity(0.05),
)); ));
return ranges; return ranges;
} }
@ -412,17 +412,15 @@ class LabResultDetails extends StatelessWidget {
} }
double? getInterval(LabViewModel labmodel) { double? getInterval(LabViewModel labmodel) {
// return .1; return .1;
var maxX = labmodel.maxY; // var maxX = labmodel.maxY;
if(maxX<1) return .3; // if(maxX<1) return .5;
if(maxX >1 && maxX <= 5) return .7; // if(maxX >1 && maxX < 5) return 1;
if(maxX >5 && maxX <= 10) return 2.5; // if(maxX >5 && maxX < 10) return 5;
if(maxX >10 && maxX <= 50) return 5; // if(maxX >10 && maxX < 50) return 10;
if(maxX >50 && maxX <= 100) return 10; // if(maxX >50 && maxX < 100) return 20;
if(maxX >100 && maxX <= 200) return 30; // if(maxX >100 && maxX < 200) return 30;
if(maxX >200 && maxX <= 300) return 50; // return 50;
if(maxX >300 && maxX <= 400) return 100;
return 200 ;
} }
Widget getLabDescription(BuildContext context) { Widget getLabDescription(BuildContext context) {

@ -257,7 +257,7 @@ class CustomGraph extends StatelessWidget {
isCurved: true, isCurved: true,
isStrokeCapRound: true, isStrokeCapRound: true,
isStrokeJoinRound: true, isStrokeJoinRound: true,
barWidth: 3, barWidth: 2,
gradient: LinearGradient( gradient: LinearGradient(
colors: [resolvedGraphColor, resolvedGraphColor], colors: [resolvedGraphColor, resolvedGraphColor],
begin: Alignment.centerLeft, begin: Alignment.centerLeft,

Loading…
Cancel
Save