|
|
|
|
@ -14,10 +14,18 @@ class LineChartCurved extends StatelessWidget {
|
|
|
|
|
List<int> xAxixs = List();
|
|
|
|
|
List<double> yAxixs = List();
|
|
|
|
|
|
|
|
|
|
double minY = 0;
|
|
|
|
|
double maxY = 0;
|
|
|
|
|
|
|
|
|
|
double minX = 0;
|
|
|
|
|
double maxX = 0;
|
|
|
|
|
double increasingY = 0;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
getXaxix();
|
|
|
|
|
getYaxix();
|
|
|
|
|
calculateMaxAndMin();
|
|
|
|
|
return AspectRatio(
|
|
|
|
|
aspectRatio: 1.1,
|
|
|
|
|
child: Container(
|
|
|
|
|
@ -70,10 +78,18 @@ class LineChartCurved extends StatelessWidget {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getYaxix() {
|
|
|
|
|
int indexess= (timeSeries.length*0.30).toInt();
|
|
|
|
|
// int indexess= (timeSeries.length*0.30).toInt();
|
|
|
|
|
// for (int index = 0; index < timeSeries.length; index++) {
|
|
|
|
|
// int mIndex = indexess * index;
|
|
|
|
|
// if (mIndex < timeSeries.length) {
|
|
|
|
|
// yAxixs.add(timeSeries[mIndex].sales);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
for (int index = 0; index < timeSeries.length; index++) {
|
|
|
|
|
int mIndex = indexess * index;
|
|
|
|
|
int mIndex = indexes * index;
|
|
|
|
|
if (mIndex < timeSeries.length) {
|
|
|
|
|
yAxixs.add(timeSeries[mIndex].sales);
|
|
|
|
|
}
|
|
|
|
|
@ -100,7 +116,6 @@ class LineChartCurved extends StatelessWidget {
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
),
|
|
|
|
|
rotateAngle:-65,
|
|
|
|
|
//rotateAngle:-65,
|
|
|
|
|
margin: 22,
|
|
|
|
|
getTitles: (value) {
|
|
|
|
|
if (timeSeries.length < 15) {
|
|
|
|
|
@ -128,18 +143,18 @@ class LineChartCurved extends StatelessWidget {
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
),
|
|
|
|
|
getTitles: (value) {
|
|
|
|
|
// if (timeSeries.length < 10) {
|
|
|
|
|
// return '${value.toInt()}';
|
|
|
|
|
// } else {
|
|
|
|
|
// if (value == getMinY())
|
|
|
|
|
// return '${value.toInt()}';
|
|
|
|
|
// if (value == getMaxY())
|
|
|
|
|
// return '${value.toInt()}';
|
|
|
|
|
// if (yAxixs.contains(value)) {
|
|
|
|
|
// return '${value.toInt()}';
|
|
|
|
|
// }
|
|
|
|
|
// return '';
|
|
|
|
|
// }
|
|
|
|
|
if (timeSeries.length < 15) {
|
|
|
|
|
return '${value.toInt()}';
|
|
|
|
|
} else {
|
|
|
|
|
if (value == minY)
|
|
|
|
|
return '${value.toInt()}';
|
|
|
|
|
if (value == getMaxY())
|
|
|
|
|
return '${value.toInt()}';
|
|
|
|
|
//if (yAxixs.contains(value)) {
|
|
|
|
|
return '${value.toInt()}';
|
|
|
|
|
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
return '${value.toInt()}';
|
|
|
|
|
},
|
|
|
|
|
margin: 12,
|
|
|
|
|
@ -163,31 +178,55 @@ class LineChartCurved extends StatelessWidget {
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
minX: 0,
|
|
|
|
|
maxX: (timeSeries.length - 1).toDouble(),
|
|
|
|
|
maxY: getMaxY()+0.3,
|
|
|
|
|
minY: getMinY(),
|
|
|
|
|
minX: minX,
|
|
|
|
|
maxX: maxX,
|
|
|
|
|
maxY: maxY,
|
|
|
|
|
minY: minY,
|
|
|
|
|
lineBarsData: getData(context),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
calculateMaxAndMin(){
|
|
|
|
|
getMaxY();
|
|
|
|
|
getMaxX();
|
|
|
|
|
getMin();
|
|
|
|
|
getMinY();
|
|
|
|
|
increasingY = ((maxY-minY)/timeSeries.length - 1)*15;
|
|
|
|
|
maxY += increasingY.abs();
|
|
|
|
|
minY -= increasingY.abs();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double getMaxY() {
|
|
|
|
|
double max = 0;
|
|
|
|
|
maxY = 0;
|
|
|
|
|
timeSeries.forEach((element) {
|
|
|
|
|
double resultValueDouble = element.sales;
|
|
|
|
|
if (resultValueDouble > maxY) maxY = resultValueDouble;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return maxY.roundToDouble() ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getMaxX(){
|
|
|
|
|
maxX = (timeSeries.length - 1).toDouble();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double getMin(){
|
|
|
|
|
minX = 0;
|
|
|
|
|
timeSeries.forEach((element) {
|
|
|
|
|
double resultValueDouble = element.sales;
|
|
|
|
|
if (resultValueDouble > max) max = resultValueDouble;
|
|
|
|
|
if (resultValueDouble < minX) minX = resultValueDouble;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return max.roundToDouble() ;
|
|
|
|
|
return minX.roundToDouble() ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double getMinY() {
|
|
|
|
|
double min = timeSeries[0].sales;
|
|
|
|
|
minY = 0;
|
|
|
|
|
timeSeries.forEach((element) {
|
|
|
|
|
double resultValueDouble = element.sales;
|
|
|
|
|
if (resultValueDouble < min) min = resultValueDouble;
|
|
|
|
|
if (resultValueDouble < minY) minY = resultValueDouble;
|
|
|
|
|
});
|
|
|
|
|
int value = min.toInt();
|
|
|
|
|
int value = minY.toInt();
|
|
|
|
|
|
|
|
|
|
return value.toDouble();
|
|
|
|
|
}
|
|
|
|
|
@ -202,7 +241,7 @@ class LineChartCurved extends StatelessWidget {
|
|
|
|
|
spots: spots,
|
|
|
|
|
isCurved: true,
|
|
|
|
|
colors: [secondaryColor],
|
|
|
|
|
barWidth: 5,
|
|
|
|
|
barWidth: 3,
|
|
|
|
|
isStrokeCapRound: true,
|
|
|
|
|
dotData: FlDotData(
|
|
|
|
|
show: false,
|
|
|
|
|
|