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!);
}
// 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++;
} catch (e) {}
});
@ -237,13 +237,12 @@ class LabsViewModel extends BaseViewModel {
threshold = _labsService.getThresholdValue();
_labsService.labOrdersResultsList.reversed.forEach((element) {
try {
print("the mapping is being done");
var dateTime = DateUtil.convertStringToDate(element.verifiedOnDateTime!);
if(double.parse(element.resultValue!)> maxYForCompleteGraph){
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 : 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) {
print("the mapping is having exception $e");
@ -260,6 +259,11 @@ class LabsViewModel extends BaseViewModel {
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 {
setState(ViewState.Busy);

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

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

Loading…
Cancel
Save