Wd: Full portrait graph added.

merge-update-with-lab-changes
Syed Taha Alam 6 months ago
parent c09170b506
commit 656d8dd6b4

@ -2337,4 +2337,5 @@ const Map localizedValues = {
"liveCareTermsConditions48": {"en": "If you have any complaints or concerns about the Application and or the Website, Our Services, or how we handle your personal information please contact us on: EServices.HMG@drsulaimanalhabib.com or call 011 525 9553", "ar": "إذا كانت لديك أي شكاوى أو مخاوف بشأن التطبيق و/أو موقع الويب أو خدماتنا أو كيفية تعاملنا مع معلوماتك الشخصية، فيرجى التواصل معنا على: EServices.HMG@drsulaimanalhabib.com أو الاتصال على الرقم: 9553 525 011"}, "liveCareTermsConditions48": {"en": "If you have any complaints or concerns about the Application and or the Website, Our Services, or how we handle your personal information please contact us on: EServices.HMG@drsulaimanalhabib.com or call 011 525 9553", "ar": "إذا كانت لديك أي شكاوى أو مخاوف بشأن التطبيق و/أو موقع الويب أو خدماتنا أو كيفية تعاملنا مع معلوماتك الشخصية، فيرجى التواصل معنا على: EServices.HMG@drsulaimanalhabib.com أو الاتصال على الرقم: 9553 525 011"},
"clickPrivacyPolicy": {"en": "Please click here to view the privacy policy", "ar": "الرجاء الضغط هنا لعرض سياسة الخصوصية"}, "clickPrivacyPolicy": {"en": "Please click here to view the privacy policy", "ar": "الرجاء الضغط هنا لعرض سياسة الخصوصية"},
"thisResult" : {"en": "This Result", "ar": "هذه النتيجة"}, "thisResult" : {"en": "This Result", "ar": "هذه النتيجة"},
"seeAllGraphValues" : {"en": "See all values", "ar": "شاهد جميع القيم"},
}; };

@ -369,8 +369,9 @@ class LabsService extends BaseService {
if (bDate == null) return -1; if (bDate == null) return -1;
return bDate.compareTo(aDate); // descending return bDate.compareTo(aDate); // descending
}); });
print("the copied item are $copy");
print("the copied item are $copy");
labOrdersResultsList = copy;
return copy.take(3).toList(); return copy.take(3).toList();
} }

@ -14,6 +14,7 @@ import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/widgets/charts/app_time_series_chart.dart'; import 'package:diplomaticquarterapp/widgets/charts/app_time_series_chart.dart';
import 'package:diplomaticquarterapp/widgets/data_display/medical/LabResult/lab_result_graph.dart'; import 'package:diplomaticquarterapp/widgets/data_display/medical/LabResult/lab_result_graph.dart';
import 'package:flutter/material.dart';
import 'package:open_filex/open_filex.dart'; import 'package:open_filex/open_filex.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
@ -25,8 +26,11 @@ class LabsViewModel extends BaseViewModel {
LabsService _labsService = locator<LabsService>(); LabsService _labsService = locator<LabsService>();
List<LabOrderResult> get labOrdersResultsList => _labsService.labOrdersResultsList; List<LabOrderResult> get labOrdersResultsList => _labsService.labOrdersResultsList;
List<DataPoint> timeSeries = []; List<DataPoint> threePointGraphValue = [];
List<DataPoint> completeeGraphValues = [];
List<ThresholdRange> threshold = []; List<ThresholdRange> threshold = [];
List months = ['Jan','Feb','Mar','April','May','Jun','July','Aug','Sep','Oct','Nov','Dec'];
String get labReportPDF => _labsService.labReportPDF; String get labReportPDF => _labsService.labReportPDF;
@ -182,22 +186,50 @@ class LabsViewModel extends BaseViewModel {
// _labsService.adjustLabOrderResults(sortedResponse); // _labsService.adjustLabOrderResults(sortedResponse);
print("the recentThree list is ${mappedToThresholdValue}"); print("the recentThree list is ${mappedToThresholdValue}");
threshold = mappedToThresholdValue; threshold = mappedToThresholdValue;
List months = ['Jan','Feb','Mar','April','May','Jun','July','Aug','Sep','Oct','Nov','Dec'];
double counter = 1; double counter = 1;
recentThree.reversed.forEach((element) { recentThree.reversed.forEach((element) {
try { try {
var dateTime = DateUtil.convertStringToDate(element.verifiedOnDateTime!); var dateTime = DateUtil.convertStringToDate(element.verifiedOnDateTime!);
timeSeries.add(DataPoint( labelValue: counter,value : _labsService.transformValueInRange(double.parse(element.resultValue!), element.calculatedResultFlag??""), label: "${months[dateTime.month]} ${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));
counter++; counter++;
} catch (e) {} } catch (e) {}
}); });
timeSeries.last.label = "thisResult"; threePointGraphValue.last.label = "thisResult";
timeSeries.last.isStringResource = true; threePointGraphValue.last.isStringResource = true;
setState(ViewState.Idle); setState(ViewState.Idle);
} }
} }
/// This function is used to create a full graph data points for the lab results.
/// @param onComplete: A callback function that is called when the data points are created.
createFullGraphDatPoints(
VoidCallback onComplete
){
completeeGraphValues.clear();
setState(ViewState.Busy);
double counter = 1;
threshold = _labsService.getThresholdValue();
_labsService.labOrdersResultsList.reversed.forEach((element) {
try {
print("the mapping is being done");
var dateTime = DateUtil.convertStringToDate(element.verifiedOnDateTime!);
completeeGraphValues.add(DataPoint( labelValue: counter,value : _labsService.transformValueInRange(double.parse(element.resultValue!), element.calculatedResultFlag??""), label: "${months[dateTime.month-1]} ${dateTime.year}", date: dateTime));
} catch (e) {
print("the mapping is having exception $e");
}
++counter;
});
print("the label values are $counter");
print("the completeeGraphValues length are ${completeeGraphValues.length}");
print("the completeeGraphValues last value of label ias ${completeeGraphValues.last.labelValue}");
completeeGraphValues.last.label = "thisResult";
completeeGraphValues.last.isStringResource = true;
setState(ViewState.Idle);
onComplete();
}
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);

@ -4745,6 +4745,7 @@ class TranslationBase {
localizedValues["clickPrivacyPolicy"][locale.languageCode]; localizedValues["clickPrivacyPolicy"][locale.languageCode];
String get thisResult => localizedValues["thisResult"][locale.languageCode]; String get thisResult => localizedValues["thisResult"][locale.languageCode];
String get seeAllGraphValues => localizedValues["seeAllGraphValues"][locale.languageCode];
String getTranslation(String label) { String getTranslation(String label) {
switch (label) { switch (label) {

@ -3,10 +3,12 @@ import 'package:diplomaticquarterapp/core/model/labs/patient_lab_orders.dart';
import 'package:diplomaticquarterapp/core/viewModels/medical/labs_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/labs_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/Loader/gif_loader_container.dart'; import 'package:diplomaticquarterapp/widgets/Loader/gif_loader_container.dart';
import 'package:diplomaticquarterapp/widgets/charts/show_chart.dart'; import 'package:diplomaticquarterapp/widgets/charts/show_chart.dart';
import 'package:diplomaticquarterapp/widgets/data_display/medical/LabResult/full_screen_lab_result_graph.dart';
import 'package:diplomaticquarterapp/widgets/data_display/medical/LabResult/lab_result_graph.dart'; import 'package:diplomaticquarterapp/widgets/data_display/medical/LabResult/lab_result_graph.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -25,109 +27,126 @@ class FlowChartPage extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
projectViewModel = Provider.of(context); projectViewModel = Provider.of(context);
return BaseView<LabsViewModel>( return BaseView<LabsViewModel>(
onModelReady: (model) => onModelReady: (model) => model.getPatientLabOrdersResults(
model.getPatientLabOrdersResults(patientLabOrder: patientLabOrder, patientLabOrder: patientLabOrder,
procedure: filterName, procedure: filterName,
isVidaPlus: Utils.isVidaPlusProject( isVidaPlus: Utils.isVidaPlusProject(
projectViewModel!, int.parse(patientLabOrder!.projectID!))), projectViewModel!, int.parse(patientLabOrder!.projectID!))),
builder: (context, model, w) => builder: (context, model, w) => SizedBox(
SizedBox( height: MediaQuery.sizeOf(context).height * .75,
height: MediaQuery child: (model.state == ViewState.Busy)
.sizeOf(context) ? Material(
.height * .75, color: Colors.grey.withOpacity(0.6),
child: (model.state == ViewState.Busy) shape: RoundedRectangleBorder(
? Material( borderRadius: BorderRadius.only(
color: Colors.grey.withOpacity(0.6), topLeft: Radius.circular(20),
shape: RoundedRectangleBorder( topRight: Radius.circular(20))),
borderRadius: BorderRadius.only( child: Center(
topLeft: Radius.circular(20), child: Container(
topRight: Radius.circular(20))), child: GifLoaderContainer(),
child: Center( margin: EdgeInsets.only(
child: Container( bottom: MediaQuery.of(context).size.height * 0.09)),
child: GifLoaderContainer(), ),
margin: EdgeInsets.only( )
bottom: MediaQuery : SingleChildScrollView(
.of(context) child: model.labOrdersResultsList.isNotEmpty
.size ? Column(
.height * 0.09)), crossAxisAlignment: CrossAxisAlignment.start,
), mainAxisSize: MainAxisSize.min,
) children: [
: SingleChildScrollView( Padding(
child: model.labOrdersResultsList.isNotEmpty padding: const EdgeInsets.only(
? Column( top: 16.0, right: 16.0, bottom: 10),
crossAxisAlignment: CrossAxisAlignment.start, child: GestureDetector(
mainAxisSize: MainAxisSize.min, onTap: () => Navigator.pop(context),
children: [ child: Align(
Padding( alignment: Alignment.centerRight,
padding: const EdgeInsets.only( child: Icon(
top: 16.0, right: 16.0, bottom: 10), Icons.close,
child: GestureDetector( color: Colors.black,
onTap: () => Navigator.pop(context), size: 28,
child: Align( ),
alignment: Alignment.centerRight, ),
child: Icon( ),
Icons.close, ),
color: Colors.black, Container(
size: 28, width: double.infinity,
), padding: EdgeInsets.only(
), left: 17, top: 12, right: 13, bottom: 12),
), margin:
), EdgeInsets.only(left: 21, right: 21, top: 21),
Container( decoration: BoxDecoration(
width: double.infinity, shape: BoxShape.rectangle,
padding: EdgeInsets.only( color: Colors.white,
left: 17, top: 12, right: 13, bottom: 12), borderRadius: BorderRadius.all(
margin: Radius.circular(10.0),
EdgeInsets.only(left: 21, right: 21, top: 21), ),
decoration: BoxDecoration( boxShadow: [
shape: BoxShape.rectangle, BoxShadow(
color: Colors.white, color: Color(0xff000000).withOpacity(.05),
borderRadius: BorderRadius.all( //spreadRadius: 5,
Radius.circular(10.0), blurRadius: 27,
), offset: Offset(0, -3),
boxShadow: [ ),
BoxShadow( ],
color: Color(0xff000000).withOpacity(.05), ),
//spreadRadius: 5, // child: LineChartCurved(
blurRadius: 27, // title: filterName,
offset: Offset(0, -3), // labResult: model.labOrdersResultsList,
// ),
// child: ShowChart(
// title: filterName!,
// timeSeries: model.timeSeries,
// indexes: model.timeSeries.length ~/ 5.5 ?? 0,
// ),
child: Column(
children: [
SizedBox(
height: MediaQuery.sizeOf(context).height / 4,
child: DynamicResultChart(
dataPoints: model.threePointGraphValue,
thresholds: model.threshold,
width: MediaQuery.sizeOf(context).width - 77,
scrollDirection: Axis.horizontal,
height: MediaQuery.sizeOf(context).height / 4,
),
),
InkWell(
onTap: () {
model.createFullGraphDatPoints(() {
Navigator.push(context,
MaterialPageRoute(builder: (_) {
return FullScreenGraph(
completeeGraphValues: model.completeeGraphValues,
threshold: model.threshold,
);
}));
});
},
child: Text(TranslationBase.of(context)
.seeAllGraphValues),
)
],
),
),
LabResultChartAndDetails(
name: filterName!,
labResult: model.labOrdersResultsList,
), ),
], ],
)
: Center(
child: Container(
padding: EdgeInsets.only(
top: MediaQuery.of(context).size.height * 0.32),
child: Center(
child: getNoDataWidget(context),
),
),
), ),
// child: LineChartCurved(
// title: filterName,
// labResult: model.labOrdersResultsList,
// ),
// child: ShowChart(
// title: filterName!,
// timeSeries: model.timeSeries,
// indexes: model.timeSeries.length ~/ 5.5 ?? 0,
// ),
child: DynamicResultChart(
dataPoints: model.timeSeries,
thresholds: model.threshold,
),
),
LabResultChartAndDetails(
name: filterName!,
labResult: model.labOrdersResultsList,
),
],
)
: Center(
child: Container(
padding: EdgeInsets.only(
top: MediaQuery
.of(context)
.size
.height * 0.32),
child: Center(
child: getNoDataWidget(context),
),
),
), ),
), ),
),
); );
} }
} }

@ -0,0 +1,59 @@
import 'package:diplomaticquarterapp/core/viewModels/medical/labs_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/medical/LabResult/lab_result_graph.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/material.dart';
class FullScreenGraph extends StatelessWidget {
final List<DataPoint> completeeGraphValues ;
final List<ThresholdRange> threshold ;
const FullScreenGraph({super.key, required this.completeeGraphValues, required this.threshold});
@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),
child: DynamicResultChart(
dataPoints: completeeGraphValues,
thresholds: threshold,
// 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,
maxX: completeeGraphValues.length.toDouble(),
scrollDirection: Axis.horizontal,
height: MediaQuery.sizeOf(context).width,
isFullScreenGraph: true,
),
),
),
),
),
);
}
// double getMax(List<DataPoint> dataPoints) {
// double max = double.negativeInfinity;
// for (var point in dataPoints) {
// if (point.value > max) {
// max = point.y;
// }
// }
// return max;
// }
}

@ -6,14 +6,26 @@ import 'package:intl/intl.dart';
class DynamicResultChart extends StatelessWidget { class DynamicResultChart extends StatelessWidget {
final List<DataPoint> dataPoints; final List<DataPoint> dataPoints;
final List<ThresholdRange> thresholds; final List<ThresholdRange> thresholds;
final double? width;
final double height;
final double? maxX;
final Axis scrollDirection;
final bool isFullScreenGraph;
const DynamicResultChart( const DynamicResultChart(
{super.key, required this.dataPoints, required this.thresholds}); {super.key, required this.dataPoints, required this.thresholds,required this.width,required this.scrollDirection, required this.height, this.maxX, this.isFullScreenGraph = false});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final minY = thresholds.first.value; var minY = 0.0;
final maxY = thresholds.last.value + 1; var maxY = 0.0;
if(thresholds.isNotEmpty) {
print("the thresholds are $thresholds");
minY = thresholds.first.value;
maxY = thresholds.last.value + 1;
}else{
return SizedBox.shrink();
}
final spots = dataPoints.asMap().entries.map((entry) { final spots = dataPoints.asMap().entries.map((entry) {
return FlSpot(entry.key.toDouble(), entry.value.value); return FlSpot(entry.key.toDouble(), entry.value.value);
@ -24,130 +36,127 @@ class DynamicResultChart extends StatelessWidget {
return Material( return Material(
color: Colors.white, color: Colors.white,
child: SizedBox( child: SizedBox(
height: MediaQuery.sizeOf(context).height / 4, width: width,
child: SingleChildScrollView( height: height,
scrollDirection: Axis.horizontal, child: Padding(
child: SizedBox( padding: const EdgeInsets.only(top: 8.0, bottom: 8),
width: MediaQuery.sizeOf(context).width - 77, child: LineChart(
child: Padding( LineChartData(
padding: const EdgeInsets.only(top: 8.0, bottom: 8), minY: minY,
child: LineChart( maxY: maxY,
LineChartData( minX: dataPoints.first.labelValue-1,
minY: minY, maxX: maxX,
maxY: maxY, lineTouchData:
minX: dataPoints.first.labelValue - 1, LineTouchData(touchTooltipData: LineTouchTooltipData(
maxX: dataPoints.first.labelValue + 1, getTooltipItems: (touchedSpots) {
lineTouchData: if (touchedSpots.isEmpty) return [];
LineTouchData(touchTooltipData: LineTouchTooltipData(
getTooltipItems: (touchedSpots) {
if (touchedSpots.isEmpty) return [];
// Only show tooltip for the first touched spot, hide others // Only show tooltip for the first touched spot, hide others
return touchedSpots.map((spot) { return touchedSpots.map((spot) {
if (spot == touchedSpots.first) { if (spot == touchedSpots.first) {
return LineTooltipItem( final dataPoint = dataPoints[spot.x.toInt()];
'${spot.y}', return LineTooltipItem(
const TextStyle(color: Colors.white), '${dataPoint.label} ${spot.y.toStringAsFixed(2)}',
); const TextStyle(color: Colors.white),
} );
return null; // hides the rest }
}).toList(); return null; // hides the rest
} }).toList();
)), }
titlesData: FlTitlesData( )),
leftTitles: AxisTitles( titlesData: FlTitlesData(
sideTitles: SideTitles( leftTitles: AxisTitles(
showTitles: true, sideTitles: SideTitles(
reservedSize: 77, showTitles: true,
interval: .1, // Let fl_chart handle it reservedSize: 77,
getTitlesWidget: (value, _) { interval: .1, // Let fl_chart handle it
// print("the value is ======== ${value}"); getTitlesWidget: (value, _) {
// print("the value is ======== ${value}");
// Compare with 2-decimal precision to avoid close duplicates // Compare with 2-decimal precision to avoid close duplicates
final matchingThreshold = thresholds.firstWhere( final matchingThreshold = thresholds.firstWhere(
(t) => (t) =>
t.value.toStringAsFixed(1) == t.value.toStringAsFixed(1) ==
value.toStringAsFixed(1), value.toStringAsFixed(1),
orElse: () => ThresholdRange( orElse: () => ThresholdRange(
label: '', label: '',
value: 0, value: 0,
color: Colors.transparent, color: Colors.transparent,
lineColor: Colors.transparent), lineColor: Colors.transparent),
); );
var actualValue = (matchingThreshold.actualValue != var actualValue = (matchingThreshold.actualValue !=
null) null)
? "${TranslationBase.of(context).getTranslation(matchingThreshold.label)} (${matchingThreshold.actualValue})" ? "${TranslationBase.of(context).getTranslation(matchingThreshold.label)} (${matchingThreshold.actualValue})"
: '${TranslationBase.of(context).getTranslation(matchingThreshold.label)}'; : '${TranslationBase.of(context).getTranslation(matchingThreshold.label)}';
if (matchingThreshold.label.isNotEmpty) { if (matchingThreshold.label.isNotEmpty) {
return Text( return Text(
actualValue, actualValue,
style: const TextStyle(fontSize: 10), style: const TextStyle(fontSize: 10),
); );
} }
return const SizedBox.shrink(); return const SizedBox.shrink();
}, },
), ),
), ),
bottomTitles: AxisTitles( bottomTitles: AxisTitles(
axisNameSize: 60, axisNameSize: 60,
sideTitles: SideTitles( sideTitles: SideTitles(
showTitles: true, showTitles: !isFullScreenGraph,
reservedSize: 50, reservedSize: 50,
getTitlesWidget: (value, _) { getTitlesWidget: (value, _) {
if (value.toInt() >= 0 && if (value.toInt() >= 0 &&
value.toInt() < dataPoints.length) { value.toInt() < dataPoints.length) {
var label = dataPoints[value.toInt()].label; var label = dataPoints[value.toInt()].label;
if (dataPoints[value.toInt()].isStringResource) { if (dataPoints[value.toInt()].isStringResource) {
label = TranslationBase.of(context) label = TranslationBase.of(context)
.getTranslation( .getTranslation(
dataPoints[value.toInt()].label); dataPoints[value.toInt()].label);
} }
return Padding(
padding: const EdgeInsets.only(top: 8.0), return Padding(
child: Text( padding: EdgeInsetsDirectional.only(top: 8.0,),
label, child: Text(
style: const TextStyle(fontSize: 12), label,
), style: const TextStyle(fontSize: 12),
);
}
return const SizedBox.shrink();
},
interval: 1, // ensures 1:1 mapping with spots
), ),
), );
topTitles: AxisTitles(), }
rightTitles: AxisTitles(), return const SizedBox.shrink();
), },
borderData: FlBorderData(show: false), interval: 1, // ensures 1:1 mapping with spots
lineBarsData:
_buildColoredLineSegments(dataPoints, thresholds),
gridData: FlGridData(show: false),
extraLinesData: ExtraLinesData(
horizontalLines: thresholds.map((t) {
return HorizontalLine(
y: t.value,
color: t.lineColor,
strokeWidth: 2,
// label: HorizontalLineLabel(
// show: true,
// alignment: Alignment.centerLeft,
// style: const TextStyle(fontSize: 10),
// labelResolver: (_) => '${t.label} (${t.value.toStringAsFixed(2)})',
// ),
);
}).toList(),
),
rangeAnnotations: RangeAnnotations(
horizontalRangeAnnotations: _buildRangeShades(thresholds),
),
),
), ),
), ),
topTitles: AxisTitles(),
rightTitles: AxisTitles(),
),
borderData: FlBorderData(show: false),
lineBarsData:
_buildColoredLineSegments(dataPoints, thresholds),
gridData: FlGridData(show: false),
extraLinesData: ExtraLinesData(
horizontalLines: thresholds.map((t) {
return HorizontalLine(
y: t.value,
color: t.lineColor,
strokeWidth: 2,
// label: HorizontalLineLabel(
// show: true,
// alignment: Alignment.centerLeft,
// style: const TextStyle(fontSize: 10),
// labelResolver: (_) => '${t.label} (${t.value.toStringAsFixed(2)})',
// ),
);
}).toList(),
),
rangeAnnotations: RangeAnnotations(
horizontalRangeAnnotations: _buildRangeShades(thresholds),
), ),
), ),
)); ),
),
));
} }
List<LineChartBarData> _buildColoredLineSegments( List<LineChartBarData> _buildColoredLineSegments(
@ -186,12 +195,13 @@ class DynamicResultChart extends StatelessWidget {
} }
// Add dot markers separately so they are on top // Add dot markers separately so they are on top
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"); print("the spots are $allSpots");
return [ var data = [
...segments, ...segments,
LineChartBarData( LineChartBarData(
spots: allSpots, spots: allSpots,
@ -212,6 +222,10 @@ class DynamicResultChart extends StatelessWidget {
), ),
) )
]; ];
var max = LineChartHelper.calculateMaxAxisValues(data).maxX;
print("the maxX is the -------> $max");
return data;
} }
List<HorizontalRangeAnnotation> _buildRangeShades( List<HorizontalRangeAnnotation> _buildRangeShades(
@ -226,6 +240,8 @@ class DynamicResultChart extends StatelessWidget {
} }
return ranges; return ranges;
} }
} }
final List<DataPoint> sampleData = [ final List<DataPoint> sampleData = [

Loading…
Cancel
Save