Merge branch 'development_new_design_2.0' of https://gitlab.com/Cloud_Solution/diplomatic-quarter into sultan_new_design
commit
821a9b5ade
@ -0,0 +1,53 @@
|
|||||||
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||||
|
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
|
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||||
|
width="612px" height="612px" viewBox="0 0 612 612" style="enable-background:new 0 0 612 612;" xml:space="preserve">
|
||||||
|
<g>
|
||||||
|
<g id="_x32__22_">
|
||||||
|
<g>
|
||||||
|
<path d="M535.5,0h-459C34.253,0,0,34.253,0,76.5v459C0,577.747,34.253,612,76.5,612h459c42.247,0,76.5-34.253,76.5-76.5v-459
|
||||||
|
C612,34.253,577.747,0,535.5,0z M229.5,459c10.557,0,19.125,8.568,19.125,19.125s-8.568,19.125-19.125,19.125h-95.089
|
||||||
|
c-5.355,0-10.156-2.219-13.617-5.757c-3.71-3.137-6.043-7.707-6.043-13.368V382.5c0-10.557,8.568-19.125,19.125-19.125
|
||||||
|
S153,371.943,153,382.5l-0.421,49.075l91.379-91.38l27.043,27.043L179.239,459H229.5z M243.958,271.824l-91.379-91.398L153,229.5
|
||||||
|
c0,10.557-8.568,19.125-19.125,19.125s-19.125-8.568-19.125-19.125v-95.625c0-5.661,2.333-10.232,6.043-13.388
|
||||||
|
c3.461-3.519,8.281-5.737,13.617-5.737H229.5c10.557,0,19.125,8.568,19.125,19.125S240.057,153,229.5,153h-50.261l91.781,91.781
|
||||||
|
L243.958,271.824z M497.25,478.125c0,5.661-2.333,10.231-6.044,13.388c-3.461,3.538-8.28,5.737-13.616,5.737H382.5
|
||||||
|
c-10.557,0-19.125-8.568-19.125-19.125S371.943,459,382.5,459h50.261l-91.781-91.781l27.043-27.042l91.379,91.379L459,382.5
|
||||||
|
c0-10.557,8.568-19.125,19.125-19.125s19.125,8.568,19.125,19.125V478.125z M497.25,229.5c0,10.557-8.568,19.125-19.125,19.125
|
||||||
|
S459,240.057,459,229.5l0.421-49.075l-91.38,91.379l-27.042-27.043L432.761,153H382.5c-10.557,0-19.125-8.568-19.125-19.125
|
||||||
|
s8.568-19.125,19.125-19.125h95.09c5.336,0,10.155,2.219,13.616,5.757c3.711,3.136,6.044,7.707,6.044,13.368V229.5z"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 2.0 KiB |
@ -0,0 +1,287 @@
|
|||||||
|
import 'package:diplomaticquarterapp/widgets/charts/app_time_series_chart.dart';
|
||||||
|
import 'package:fl_chart/fl_chart.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../Constants.dart';
|
||||||
|
|
||||||
|
class ShowChart extends StatelessWidget {
|
||||||
|
final String title;
|
||||||
|
final List<TimeSeriesSales2> timeSeries;
|
||||||
|
final int indexes;
|
||||||
|
final double horizontalInterval;
|
||||||
|
|
||||||
|
ShowChart({this.title, this.timeSeries, this.indexes, this.horizontalInterval = 20.0});
|
||||||
|
|
||||||
|
List<int> xAxixs = List();
|
||||||
|
List<double> yAxixs = List();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
getXaxix();
|
||||||
|
getYaxix();
|
||||||
|
return AspectRatio(
|
||||||
|
aspectRatio: 1.0,
|
||||||
|
child: Container(
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(18)),
|
||||||
|
// color: Colors.white,
|
||||||
|
),
|
||||||
|
child: Stack(
|
||||||
|
children: <Widget>[
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: <Widget>[
|
||||||
|
const SizedBox(
|
||||||
|
height: 4,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
title,
|
||||||
|
style: TextStyle(color: Colors.black, fontSize: 16, letterSpacing: -0.64, fontWeight: FontWeight.w600),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 18.0, left: 16.0),
|
||||||
|
child: LineChart(
|
||||||
|
sampleData1(context),
|
||||||
|
swapAnimationDuration: const Duration(milliseconds: 250),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
getXaxix() {
|
||||||
|
for (int index = 0; index < timeSeries.length; index++) {
|
||||||
|
int mIndex = indexes * index;
|
||||||
|
if (mIndex < timeSeries.length) {
|
||||||
|
xAxixs.add(mIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getYaxix() {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// LineChartData sampleData1(context) {
|
||||||
|
// return LineChartData(
|
||||||
|
// lineTouchData: LineTouchData(
|
||||||
|
// touchTooltipData: LineTouchTooltipData(
|
||||||
|
// tooltipBgColor: Colors.white,
|
||||||
|
// ),
|
||||||
|
// touchCallback: (LineTouchResponse touchResponse) {},
|
||||||
|
// handleBuiltInTouches: true,
|
||||||
|
// ),
|
||||||
|
// gridData: FlGridData(show: true, drawVerticalLine: true, drawHorizontalLine: true, horizontalInterval: 14, verticalInterval: 14),
|
||||||
|
// titlesData: FlTitlesData(
|
||||||
|
// bottomTitles: SideTitles(
|
||||||
|
// showTitles: true,
|
||||||
|
// getTextStyles: (value) => const TextStyle(
|
||||||
|
// color: Colors.black,
|
||||||
|
// fontSize: 10,
|
||||||
|
// ),
|
||||||
|
// // rotateAngle: 90,
|
||||||
|
// //rotateAngle:-65,
|
||||||
|
// margin: 22,
|
||||||
|
// getTitles: (value) {
|
||||||
|
// if (timeSeries.length < 15) {
|
||||||
|
// if (timeSeries.length > value.toInt()) {
|
||||||
|
// return '${timeSeries[value.toInt()].time.month}/ ${timeSeries[value.toInt()].time.year}';
|
||||||
|
// } else
|
||||||
|
// return '';
|
||||||
|
// } else {
|
||||||
|
// if (value.toInt() == 0) return '${timeSeries[value.toInt()].time.month}/ ${timeSeries[value.toInt()].time.year}';
|
||||||
|
// if (value.toInt() == timeSeries.length - 1) return '${timeSeries[value.toInt()].time.month}/ ${timeSeries[value.toInt()].time.year}';
|
||||||
|
// if (xAxixs.contains(value.toInt())) {
|
||||||
|
// return '${timeSeries[value.toInt()].time.month}/ ${timeSeries[value.toInt()].time.year}';
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return '';
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// leftTitles: SideTitles(
|
||||||
|
// showTitles: true,
|
||||||
|
// // interval:getMaxY() - getMinY() <=500?50:getMaxY() - getMinY() <=1000?100:200,
|
||||||
|
// interval: 3,
|
||||||
|
// getTextStyles: (value) => const TextStyle(
|
||||||
|
// color: Colors.black,
|
||||||
|
// fontWeight: FontWeight.bold,
|
||||||
|
// fontSize: 10,
|
||||||
|
// ),
|
||||||
|
//
|
||||||
|
// margin: 12,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// borderData: FlBorderData(
|
||||||
|
// show: true,
|
||||||
|
// border: const Border(
|
||||||
|
// bottom: BorderSide(
|
||||||
|
// color: Colors.black,
|
||||||
|
// width: 0.5,
|
||||||
|
// ),
|
||||||
|
// left: BorderSide(
|
||||||
|
// color: Colors.black,
|
||||||
|
// ),
|
||||||
|
// right: BorderSide(
|
||||||
|
// color: Colors.black,
|
||||||
|
// ),
|
||||||
|
// top: BorderSide(
|
||||||
|
// color: Colors.transparent,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// minX: 0,
|
||||||
|
// maxX: (timeSeries.length - 1).toDouble(),
|
||||||
|
// maxY: getMaxY() + 0.3,
|
||||||
|
// minY: 0,
|
||||||
|
// //getMinY(),
|
||||||
|
// lineBarsData: getData(context),
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
LineChartData sampleData1(context) {
|
||||||
|
return LineChartData(
|
||||||
|
lineTouchData: LineTouchData(
|
||||||
|
touchTooltipData: LineTouchTooltipData(
|
||||||
|
tooltipBgColor: Colors.white,
|
||||||
|
),
|
||||||
|
touchCallback: (LineTouchResponse touchResponse) {},
|
||||||
|
handleBuiltInTouches: true,
|
||||||
|
),
|
||||||
|
gridData: FlGridData(show: true, drawVerticalLine: true, drawHorizontalLine: true, horizontalInterval: 14, verticalInterval: 14),
|
||||||
|
titlesData: FlTitlesData(
|
||||||
|
bottomTitles: SideTitles(
|
||||||
|
showTitles: true,
|
||||||
|
getTextStyles: (value) => const TextStyle(
|
||||||
|
color: Colors.black,
|
||||||
|
fontSize: 10,
|
||||||
|
),
|
||||||
|
rotateAngle: -65,
|
||||||
|
margin: 22,
|
||||||
|
getTitles: (value) {
|
||||||
|
if (timeSeries.length < 15) {
|
||||||
|
if (timeSeries.length > value.toInt()) {
|
||||||
|
return '${timeSeries[value.toInt()].time.month}/ ${timeSeries[value.toInt()].time.year}';
|
||||||
|
} else
|
||||||
|
return '';
|
||||||
|
} else {
|
||||||
|
if (value.toInt() == 0) return '${timeSeries[value.toInt()].time.month}/ ${timeSeries[value.toInt()].time.year}';
|
||||||
|
if (value.toInt() == timeSeries.length - 1) return '${timeSeries[value.toInt()].time.month}/ ${timeSeries[value.toInt()].time.year}';
|
||||||
|
if (xAxixs.contains(value.toInt())) {
|
||||||
|
return '${timeSeries[value.toInt()].time.month}/ ${timeSeries[value.toInt()].time.year}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
),
|
||||||
|
leftTitles: SideTitles(
|
||||||
|
showTitles: true,
|
||||||
|
getTextStyles: (value) => const TextStyle(
|
||||||
|
color: Colors.black,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 10,
|
||||||
|
),
|
||||||
|
interval: 3.0,
|
||||||
|
// interval: getMaxY() - getMinY() <= 500
|
||||||
|
// ? getMaxY() - getMinY() <= 50
|
||||||
|
// ? 10
|
||||||
|
// : 10
|
||||||
|
// : getMaxY() - getMinY() <= 1000
|
||||||
|
// ? 100
|
||||||
|
// : getMaxY() - getMinY() >= 10000
|
||||||
|
// ? 5000
|
||||||
|
// : 200,
|
||||||
|
margin: 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
borderData: FlBorderData(
|
||||||
|
show: true,
|
||||||
|
border: const Border(
|
||||||
|
bottom: BorderSide(
|
||||||
|
color: Colors.black,
|
||||||
|
width: 0.5,
|
||||||
|
),
|
||||||
|
left: BorderSide(
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
right: BorderSide(
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
top: BorderSide(
|
||||||
|
color: Colors.transparent,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
minX: 0,
|
||||||
|
maxX: (timeSeries.length - 1).toDouble(),
|
||||||
|
maxY: getMaxY() + 0.3,
|
||||||
|
minY: 0,
|
||||||
|
//getMinY(),
|
||||||
|
lineBarsData: getData(context),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
double getMaxY() {
|
||||||
|
double max = 0;
|
||||||
|
timeSeries.forEach((element) {
|
||||||
|
double resultValueDouble = element.sales;
|
||||||
|
if (resultValueDouble > max) max = resultValueDouble;
|
||||||
|
});
|
||||||
|
|
||||||
|
return max.roundToDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
double getMinY() {
|
||||||
|
double min = timeSeries.isEmpty ? 0 : timeSeries.first.sales;
|
||||||
|
timeSeries.forEach((element) {
|
||||||
|
double resultValueDouble = element.sales;
|
||||||
|
if (resultValueDouble < min) min = resultValueDouble;
|
||||||
|
});
|
||||||
|
int value = min.toInt();
|
||||||
|
|
||||||
|
return value.toDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<LineChartBarData> getData(context) {
|
||||||
|
List<FlSpot> spots = List();
|
||||||
|
for (int index = 0; index < timeSeries.length; index++) {
|
||||||
|
spots.add(FlSpot(index.toDouble(), timeSeries[index].sales));
|
||||||
|
}
|
||||||
|
|
||||||
|
final LineChartBarData lineChartBarData1 = LineChartBarData(
|
||||||
|
spots: spots,
|
||||||
|
isCurved: true,
|
||||||
|
colors: [secondaryColor],
|
||||||
|
barWidth: 1.5,
|
||||||
|
isStrokeCapRound: true,
|
||||||
|
dotData: FlDotData(
|
||||||
|
show: false,
|
||||||
|
),
|
||||||
|
belowBarData: BarAreaData(
|
||||||
|
show: false,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
return [
|
||||||
|
lineChartBarData1,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue