WD: bottom date titles are added with custom height and maxX

lab_result
taha.alam 2 months ago
parent 8348557254
commit b6d310c65f

@ -213,7 +213,7 @@ class LabsViewModel extends BaseViewModel {
maxYForThreeDots = double.parse(element.resultValue!); maxYForThreeDots = double.parse(element.resultValue!);
} }
// threePointGraphValue.add(DataPoint( labelValue: counter,value : _labsService.transformValueInRange(double.parse(element.resultValue!), element.calculatedResultFlag??""), label: "${months[dateTime.month-1]} ${dateTime.year}", date: dateTime)); // threePointGraphValue.add(DataPoint( labelValue: counter,value : _labsService.transformValueInRange(double.parse(element.resultValue!), element.calculatedResultFlag??""), label: "${months[dateTime.month-1]} ${dateTime.year}", date: dateTime));
threePointGraphValue.add(DataPoint( labelValue: counter,value : double.parse(element.resultValue!), actualValue: element.resultValue!,label: "${months[dateTime.month-1]} ${dateTime.year}", date: dateTime, referenceRangeValue:element.calculatedResultFlag ??"IRR")); threePointGraphValue.add(DataPoint( labelValue: counter,value : double.parse(element.resultValue!), actualValue: element.resultValue!,label: formatDateAsMMYY(dateTime), date: dateTime, referenceRangeValue:element.calculatedResultFlag ??"IRR"));
counter++; counter++;
} catch (e) {} } catch (e) {}
}); });
@ -237,13 +237,12 @@ class LabsViewModel extends BaseViewModel {
threshold = _labsService.getThresholdValue(); threshold = _labsService.getThresholdValue();
_labsService.labOrdersResultsList.reversed.forEach((element) { _labsService.labOrdersResultsList.reversed.forEach((element) {
try { try {
print("the mapping is being done");
var dateTime = DateUtil.convertStringToDate(element.verifiedOnDateTime!); var dateTime = DateUtil.convertStringToDate(element.verifiedOnDateTime!);
if(double.parse(element.resultValue!)> maxYForCompleteGraph){ if(double.parse(element.resultValue!)> maxYForCompleteGraph){
maxYForCompleteGraph = double.parse(element.resultValue!); maxYForCompleteGraph = double.parse(element.resultValue!);
} }
// completeeGraphValues.add(DataPoint( labelValue: counter,value : _labsService.transformValueInRange(double.parse(element.resultValue!), element.calculatedResultFlag??""), label: "${months[dateTime.month-1]} ${dateTime.year}", date: dateTime)); // completeeGraphValues.add(DataPoint( labelValue: counter,value : _labsService.transformValueInRange(double.parse(element.resultValue!), element.calculatedResultFlag??""), label: "${months[dateTime.month-1]} ${dateTime.year}", date: dateTime));
completeeGraphValues.add(DataPoint( labelValue: counter,value : double.parse(element.resultValue!), label: "${months[dateTime.month-1]} ${dateTime.year}", date: dateTime,actualValue: element.resultValue!, referenceRangeValue:element.calculatedResultFlag??"IRR" )); completeeGraphValues.add(DataPoint( labelValue: counter,value : double.parse(element.resultValue!), label: formatDateAsMMYY(dateTime), date: dateTime,actualValue: element.resultValue!, referenceRangeValue:element.calculatedResultFlag??"IRR" ));
} catch (e) { } catch (e) {
print("the mapping is having exception $e"); print("the mapping is having exception $e");
@ -260,6 +259,11 @@ class LabsViewModel extends BaseViewModel {
onComplete(); onComplete();
} }
String formatDateAsMMYY(DateTime date) {
String month = date.month.toString().padLeft(2, '0');
String year = date.year.toString().substring(2);
return '$month/$year';
}
sendLabReportEmail({PatientLabOrders? patientLabOrder, String? mes, AuthenticatedUser? userObj, required bool isVidaPlus, bool isDownload = false}) async { sendLabReportEmail({PatientLabOrders? patientLabOrder, String? mes, AuthenticatedUser? userObj, required bool isVidaPlus, bool isDownload = false}) async {
setState(ViewState.Busy); setState(ViewState.Busy);

@ -6,55 +6,67 @@ import 'package:hmg_patient_app/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class FullScreenGraph extends StatelessWidget { class FullScreenGraph extends StatelessWidget {
final List<DataPoint> completeeGraphValues ; final List<DataPoint> completeeGraphValues;
final List<ThresholdRange> threshold ;
final double maxY ; final List<ThresholdRange> threshold;
final double maxY;
const FullScreenGraph(
{super.key,
required this.completeeGraphValues,
required this.threshold,
required this.maxY});
const FullScreenGraph({super.key, required this.completeeGraphValues, required this.threshold, required this. maxY});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AppScaffold( return AppScaffold(
isShowAppBar: true, isShowAppBar: true,
appBarTitle: TranslationBase.of(context).labResult, appBarTitle: TranslationBase.of(context).labResult,
showNewAppBar: true, showNewAppBar: true,
showNewAppBarTitle: true, showNewAppBarTitle: true,
backgroundColor: Color(0xffF8F8F8), backgroundColor: Color(0xffF8F8F8),
body: RotatedBox( body: RotatedBox(
quarterTurns: 1, quarterTurns: 1,
child: SizedBox( child: SizedBox(
// width: MediaQuery.sizeOf(context).height, // width: MediaQuery.sizeOf(context).height,
height: MediaQuery.sizeOf(context).width, height: MediaQuery.sizeOf(context).width,
child: Material( child: Material(
color: Colors.white, color: Colors.white,
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 18), padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 18),
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: DynamicResultChart( child: DynamicResultChart(
dataPoints: completeeGraphValues, dataPoints: completeeGraphValues,
thresholds: threshold, thresholds: threshold,
maxY : maxY, maxY: maxY,
// width:((completeeGraphValues.length <=2)? MediaQuery.sizeOf(context).height : (MediaQuery.sizeOf(context).height* ( width:((completeeGraphValues.length <=2)? MediaQuery.sizeOf(context).height : (MediaQuery.sizeOf(context).height* (
// completeeGraphValues.length <= 3 completeeGraphValues.length <= 15
// ? 1 ? 1
// : (completeeGraphValues.length/3)) : (completeeGraphValues.length/15))
// ) )-77, ) )-100,
width: MediaQuery.sizeOf(context).height-100, maxX: completeeGraphValues.length+1,
// width: MediaQuery.sizeOf(context).height - 100,
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
height: MediaQuery.sizeOf(context).width, height: MediaQuery.sizeOf(context).width,
isFullScreenGraph: true, showBottomTitleDates: true,
isFullScreeGraph: true,
), ),
), ),
), ),
), ),
), ),
); ),
);
} }
// double getMax(List<DataPoint> dataPoints) { // double getMax(List<DataPoint> dataPoints) {
// double max = double.negativeInfinity; // double max = double.negativeInfinity;
// for (var point in dataPoints) { // for (var point in dataPoints) {
// if (point.value > max) { // if (point.value > max) {
// max = point.y; // max = point.y;
// } // }
// } // }
// return max; // return max;
// } // }
} }

@ -9,18 +9,19 @@ class DynamicResultChart extends StatelessWidget {
final double? width; final double? width;
final double height; final double height;
final double? maxY; final double? maxY;
final double? maxX;
final Axis scrollDirection; final Axis scrollDirection;
final bool isFullScreenGraph; final bool showBottomTitleDates;
final bool isFullScreeGraph;
DynamicResultChart( DynamicResultChart(
{super.key, required this.dataPoints, required this.thresholds, required this.width, required this.scrollDirection, required this.height, this.maxY, this.isFullScreenGraph = false}); {super.key, required this.dataPoints, required this.thresholds, this.width, required this.scrollDirection, required this.height, this.maxY,this.maxX, this.showBottomTitleDates = true, this.isFullScreeGraph = false});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var minY = 0.0; var minY = 0.0;
// var maxY = 0.0; // var maxY = 0.0;
print("the maxY from parameter is $maxY");
double interval = 20; double interval = 20;
if((maxY??0)>10 &&(maxY??0)<=20) interval = 2; if((maxY??0)>10 &&(maxY??0)<=20) interval = 2;
else if((maxY??0)>5 &&(maxY??0)<=10) interval = 1; else if((maxY??0)>5 &&(maxY??0)<=10) interval = 1;
@ -54,7 +55,7 @@ class DynamicResultChart extends StatelessWidget {
minY: 0, minY: 0,
maxY: ((maxY?.ceilToDouble()??0.0)+interval ).floorToDouble(), maxY: ((maxY?.ceilToDouble()??0.0)+interval ).floorToDouble(),
// minX: dataPoints.first.labelValue - 1, // minX: dataPoints.first.labelValue - 1,
// maxX: maxX, maxX: maxX,
lineTouchData: LineTouchData(touchTooltipData: LineTouchTooltipData(getTooltipItems: (touchedSpots) { lineTouchData: LineTouchData(touchTooltipData: LineTouchTooltipData(getTooltipItems: (touchedSpots) {
if (touchedSpots.isEmpty) return []; if (touchedSpots.isEmpty) return [];
@ -130,7 +131,7 @@ class DynamicResultChart extends StatelessWidget {
bottomTitles: AxisTitles( bottomTitles: AxisTitles(
axisNameSize: 60, axisNameSize: 60,
sideTitles: SideTitles( sideTitles: SideTitles(
showTitles: !isFullScreenGraph, showTitles: showBottomTitleDates,
reservedSize: 50, reservedSize: 50,
getTitlesWidget: (value, _) { getTitlesWidget: (value, _) {
if (value.toInt() >= 0 && value.toInt() < dataPoints.length) { if (value.toInt() >= 0 && value.toInt() < dataPoints.length) {
@ -198,7 +199,6 @@ class DynamicResultChart extends StatelessWidget {
List<LineChartBarData> _buildColoredLineSegments(List<DataPoint> dataPoints, List<ThresholdRange> thresholds) { List<LineChartBarData> _buildColoredLineSegments(List<DataPoint> dataPoints, List<ThresholdRange> thresholds) {
List<LineChartBarData> segments = []; List<LineChartBarData> segments = [];
Color getColor(String value) { Color getColor(String value) {
print("the value to compare is $value");
for (int i = thresholds.length - 1; i >= 0; i--) { for (int i = thresholds.length - 1; i >= 0; i--) {
if (value == thresholds[i].label) { if (value == thresholds[i].label) {
return thresholds[i].lineColor; return thresholds[i].lineColor;
@ -249,7 +249,6 @@ class DynamicResultChart extends StatelessWidget {
final List<FlSpot> allSpots = dataPoints.asMap().entries.map((entry) { final List<FlSpot> allSpots = dataPoints.asMap().entries.map((entry) {
return FlSpot(entry.key.toDouble(), entry.value.value); return FlSpot(entry.key.toDouble(), entry.value.value);
}).toList(); }).toList();
print("the spots are $allSpots");
var data = [ var data = [
// ...segments // ...segments
@ -258,7 +257,7 @@ class DynamicResultChart extends StatelessWidget {
isCurved: true, isCurved: true,
isStrokeCapRound: true, isStrokeCapRound: true,
isStrokeJoinRound: true, isStrokeJoinRound: true,
barWidth: 2, // invisible line barWidth: 2,
gradient: LinearGradient( gradient: LinearGradient(
colors: [Color(0xFF5dc36b), Color(0xFF5dc36b)], colors: [Color(0xFF5dc36b), Color(0xFF5dc36b)],
begin: Alignment.centerLeft, begin: Alignment.centerLeft,

Loading…
Cancel
Save