|
|
|
|
@ -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,
|
|
|
|
|
|