Line Chart Fix in Vital Signs

merge-update-with-lab-changes
Mirza.Shafique 4 years ago
parent 350882b1d2
commit 8a4cf9f23b

@ -12,8 +12,8 @@ const PACKAGES_PRODUCTS = '/api/products';
const PACKAGES_CUSTOMER = '/api/customers'; const PACKAGES_CUSTOMER = '/api/customers';
const PACKAGES_SHOPPING_CART = '/api/shopping_cart_items'; const PACKAGES_SHOPPING_CART = '/api/shopping_cart_items';
const PACKAGES_ORDERS = '/api/orders'; const PACKAGES_ORDERS = '/api/orders';
// const BASE_URL = 'https://uat.hmgwebservices.com/'; const BASE_URL = 'https://uat.hmgwebservices.com/';
const BASE_URL = 'https://hmgwebservices.com/'; // const BASE_URL = 'https://hmgwebservices.com/';
// Pharmacy UAT URLs // Pharmacy UAT URLs
const BASE_PHARMACY_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; const BASE_PHARMACY_URL = 'https://uat.hmgwebservices.com/epharmacy/api/';

@ -96,8 +96,8 @@ class _HomePageFragment2State extends State<HomePageFragment2> {
margin: EdgeInsets.only(left: 20, right: 20, top: 8, bottom: 6), margin: EdgeInsets.only(left: 20, right: 20, top: 8, bottom: 6),
child: SliderView( child: SliderView(
onLoginClick: () { onLoginClick: () {
// widget.onLoginClick(); widget.onLoginClick();
navigateTo(context, CallHomePage()); // navigateTo(context, CallHomePage());
}, },
), ),
// height: MediaQuery.of(context).size.width / 2.6, // height: MediaQuery.of(context).size.width / 2.6,

@ -17,6 +17,8 @@ class LineChartCurved extends StatelessWidget {
double minY = 0; double minY = 0;
double maxY = 0; double maxY = 0;
double intialY = 0;
double lastY = 0;
double minX = 0; double minX = 0;
double maxX = 0; double maxX = 0;
@ -26,6 +28,7 @@ class LineChartCurved extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
getXaxix(); getXaxix();
getYaxix(); getYaxix();
getInitialY();
calculateMaxAndMin(); calculateMaxAndMin();
return AspectRatio( return AspectRatio(
aspectRatio: 1.0, aspectRatio: 1.0,
@ -100,7 +103,7 @@ class LineChartCurved extends StatelessWidget {
touchCallback: (LineTouchResponse touchResponse) {}, touchCallback: (LineTouchResponse touchResponse) {},
handleBuiltInTouches: true, handleBuiltInTouches: true,
), ),
gridData: FlGridData(show: true, drawVerticalLine: true, drawHorizontalLine: true,horizontalInterval: 14,verticalInterval: 14), gridData: FlGridData(show: true, drawVerticalLine: true, drawHorizontalLine: true, horizontalInterval: 14, verticalInterval: 14),
titlesData: FlTitlesData( titlesData: FlTitlesData(
bottomTitles: SideTitles( bottomTitles: SideTitles(
showTitles: true, showTitles: true,
@ -165,12 +168,14 @@ class LineChartCurved extends StatelessWidget {
), ),
minX: minX, minX: minX,
maxX: maxX, maxX: maxX,
maxY: maxY, maxY: lastY+50,
minY: 0, minY: intialY,
lineBarsData: getData(context), lineBarsData: getData(context),
); );
} }
calculateMaxAndMin() { calculateMaxAndMin() {
getMaxY(); getMaxY();
getMaxX(); getMaxX();
@ -185,12 +190,29 @@ class LineChartCurved extends StatelessWidget {
maxY = 0; maxY = 0;
timeSeries.forEach((element) { timeSeries.forEach((element) {
double resultValueDouble = element.sales; double resultValueDouble = element.sales;
if (resultValueDouble > maxY) maxY = resultValueDouble; if (resultValueDouble > maxY) {
lastY = resultValueDouble;
maxY = resultValueDouble;
}
}); });
print("maxY " + lastY.toString());
return maxY.roundToDouble(); return maxY.roundToDouble();
} }
double getInitialY() {
try {
intialY = timeSeries.first.sales;
timeSeries.forEach((element) {
double resultValueDouble = element.sales;
if (resultValueDouble < intialY) intialY = resultValueDouble;
});
} catch (e) {
intialY = 0;
}
return intialY.roundToDouble();
}
getMaxX() { getMaxX() {
maxX = (timeSeries.length - 1).toDouble(); maxX = (timeSeries.length - 1).toDouble();
} }

Loading…
Cancel
Save