Files
backend/public/dist/js/biNew.js
2024-02-01 09:53:53 +00:00

4547 lines
124 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
var feaLayer = []
var resu;
var provincesArray;
var pahneArray = [];
var citiesArray;
var iranGeoJSON;
var iranMapGeo;
var iranArrayCount = 0;
var iranCityCount = 0;
var keepMapFeatureColor = null;
var fullCityGeoJSONTemp = new Object();
var fullCityGeoJSON = null;
var iranCityMapGeo;
var flagProvince = 0;
var flagCity = 0;
var HopeData;
var statusSet;
var sortable = [];
var sortable2 = [];
var minOfPahne;
var maxOfPahne;
var damaneh;
var charak;
var charakAval;
var charakDovom;
var rahdariPercent;
var pageUrl = window.location.href;
var ajaxUrl = new URL("https://rms.rmto.ir/api/milad");
var myChartSixth
var myChartJariSecond
var myChart23
var indexCol = 1;
//project
//daily
//misson
// handle
//danger95
// danger99
// block
var dataSix = [];
var forRefresh = $('#dateTo').val();
var forRefresh2 = $('#dateFrom').val()
window.addEventListener('resize', function () {
// //console.log(
// Chart.instances );
//console.log("inaro ki yadet dad");
// Chart.instances[6].resize();
});
$(document).ready(function () {
$.ajax({
url: "https://rms.rmto.ir/public/contents/provinces",
type: "GET",
cache: false,
contentType: false,
processData: false,
success: function (result) {
provincesArray = result.data;
// feaLayer = result.data;
$.ajax({
url: "https://rms.rmto.ir/api/milad?i=1",
// url: "https://rms.rmto.ir/public/bama-homepage",
type: "GET",
cache: false,
success: function (result) {
//console.log("apiRes",result);
resu = result;
ShowBi(result);
},
error: function (error) {
//console.log(error);
},
});
},
error: function (error) { },
});
init_province_filter();
});
//in normal way of filtering
$("#select-month").prop("disabled", true);
$("#dateFrom").prop("disabled", true);
$("#dateTo").prop("disabled", true);
//in normal way of filtering
var bounds = [
[42.9130026312, 75.6166317076],
[20.5782370061, 30.5092252948],
];
const MAP_ENDPOINT = "https://rmsmap.rmto.ir";
const MAP_MIN_ZOOM = 4.2;
const MAP_MAX_ZOOM = 15;
var map = L.map("map", {
maxBounds: bounds,
minZoom: MAP_MIN_ZOOM,
//maxZoom: MAP_MAX_ZOOM,
zoomControl: true,
}).setView([32.4279, 53.6880], 5);
L.tileLayer(MAP_ENDPOINT + "/141map/{z}/{x}/{y}.png", {}).addTo(map);
map.zoomControl.setPosition('topright');
// var map2 = L.map("map2", {
// maxBounds: bounds,
// minZoom: MAP_MIN_ZOOM,
// //maxZoom: MAP_MAX_ZOOM,
// zoomControl: false,
// }).setView([32.4279, 53.6880], 4.2);
// L.tileLayer(MAP_ENDPOINT + "/141map/{z}/{x}/{y}.png", {}).addTo(map2);
var chartColors = [
"#4929ac",
"#202be0",
"#4962ac",
"#4286d3",
"#000c7f",
"#2aa9db",
"#8690ef",
"#00587a",
"#88b3cb",
"rgba(255, 64, 255, 1)",
"rgba(159, 159, 64, 1)",
"#ff5c0f",
"#4962ac",
];
Chart.defaults.global.defaultFontFamily = "IRANSansFaNum";
var progressBar = document.getElementById("progressBar")
var bar = new ProgressBar.SemiCircle(progressBar, {
strokeWidth: 20,
color: '#FFEA82',
trailColor: '#FFEA82',
trailWidth: 20,
easing: 'easeInOut',
duration: 1400,
svgStyle: null,
text: {
value: '',
alignToBottom: false
},
from: { color: '#FFEA82' },
to: { color: '#ED6A5A' },
// Set default step function for all animate calls
step: (state, bar) => {
bar.path.setAttribute('stroke', state.color);
var value = Math.round(bar.value() * 100);
if (value === 0) {
bar.setText('');
} else {
bar.setText(value);
}
bar.text.style.color = state.color;
}
});
bar.text.style.fontFamily = '"Raleway", Helvetica, sans-serif';
bar.text.style.fontSize = '1rem';
// bar.animate(0.87);
// Number from 0.0 to 1.0
// var ThirdChart = document.getElementById("myChartThird").getContext("2d");
// var myChartThird = new Chart(ThirdChart, {
// type: "horizontalBar",
// data: {
// datasets: [
// {
// data: [
// 100,
// 98,
// 87,
// ],
// backgroundColor: [
// chartColors[0],
// chartColors[1],
// chartColors[2],
// ],
// label: "hey"
// },
// ],
// labels: [
// "",
// "",
// "",
// ],
// },
// options: {
// scales: {
// yAxes: [{
// ticks: {
// suggestedMin: 0,
// suggestedMax: 1017
// }
// }],
// xAxes: [{
// ticks: {
// min: 0
// }
// }]
// },
// plugins: {
// datalabels: {
// anchor: "center",
// align: "center",
// offset: 10,
// color: "#fffff",
// },
// },
// responsive: true,
// legend: {
// display: false,
// position: "left",
// },
// title: {
// display: false,
// text: "تفکیک پروژه های راه روستایی",
// position: "bottom",
// },
// tooltips: {
// enabled: false,
// },
// },
// });
// var ForthChart = document.getElementById("myChartForth").getContext("2d");
// var myChartForth = new Chart(ForthChart, {
// type: "horizontalBar",
// data: {
// datasets: [
// {
// data: [
// 127,
// 110,
// 95,
// ],
// backgroundColor: [
// chartColors[0],
// chartColors[1],
// chartColors[2],
// ],
// label: "hey"
// },
// ],
// labels: [
// "",
// "",
// "",
// ],
// },
// options: {
// scales: {
// yAxes: [{
// ticks: {
// suggestedMin: 0,
// suggestedMax: 1017
// }
// }],
// xAxes: [{
// ticks: {
// min: 0
// }
// }]
// },
// plugins: {
// datalabels: {
// anchor: "center",
// align: "center",
// offset: 10,
// color: "#fffff",
// },
// },
// responsive: true,
// legend: {
// display: false,
// position: "left",
// },
// title: {
// display: false,
// text: "تفکیک پروژه های راه روستایی",
// position: "bottom",
// },
// tooltips: {
// enabled: false,
// },
// },
// });
// var FifthChart = document.getElementById("myChartFifth").getContext("2d");
// var myChartFifth = new Chart(FifthChart, {
// type: "bar",
// data: {
// datasets: [
// {
// data: [
// 127,
// 110,
// 95,
// ],
// backgroundColor: [
// chartColors[0],
// chartColors[1],
// chartColors[2],
// ],
// label: "hey"
// },
// {
// data: [
// 127,
// 110,
// 95,
// ],
// backgroundColor: [
// chartColors[3],
// chartColors[4],
// chartColors[5],
// ],
// label: "hey"
// },
// {
// data: [
// 127,
// 110,
// 95,
// ],
// backgroundColor: [
// chartColors[6],
// chartColors[7],
// chartColors[8],
// ],
// label: "hey"
// },
// {
// data: [
// 127,
// 110,
// 95,
// ],
// backgroundColor: [
// chartColors[9],
// chartColors[10],
// chartColors[11],
// ],
// label: "hey"
// },
// ],
// labels: [
// "",
// "",
// "",
// ],
// },
// options: {
// scales: {
// yAxes: [{
// stacked: true,
// ticks: {
// suggestedMin: 0,
// suggestedMax: 1017
// }
// }],
// xAxes: [{
// stacked: true,
// ticks: {
// min: 0
// }
// }]
// },
// plugins: {
// datalabels: {
// anchor: "center",
// align: "center",
// offset: 10,
// color: "#fffff",
// },
// },
// responsive: true,
// legend: {
// display: false,
// position: "left",
// },
// title: {
// display: false,
// text: "تفکیک پروژه های راه روستایی",
// position: "bottom",
// },
// tooltips: {
// enabled: false,
// },
// },
// });
// var EighthChart = document.getElementById("myChartEighth").getContext("2d");
// var myChartEighth = new Chart(EighthChart, {
// type: "bar",
// data: {
// datasets: [
// {
// data: [
// -16,
// -30, 60,
// ],
// backgroundColor: [
// chartColors[0],
// chartColors[1],
// ],
// label: "hey"
// },
// {
// data: [
// 127,
// 110,
// ],
// backgroundColor: [
// chartColors[2],
// chartColors[3],
// ],
// label: "hey"
// },
// ],
// labels: [
// "",
// "",
// ],
// },
// options: {
// scales: {
// yAxes: [{
// stacked: true,
// ticks: {
// suggestedMin: 0,
// suggestedMax: 100
// }
// }],
// xAxes: [{
// stacked: true,
// ticks: {
// min: 0
// }
// }]
// },
// plugins: {
// datalabels: {
// anchor: "center",
// align: "center",
// offset: 10,
// color: "#fffff",
// },
// },
// responsive: true,
// legend: {
// display: false,
// position: "left",
// },
// title: {
// display: false,
// text: "تفکیک پروژه های راه روستایی",
// position: "bottom",
// },
// tooltips: {
// enabled: false,
// },
// },
// });
// var NinthChart = document.getElementById("myChartNinth").getContext("2d");
// var myChartNinth = new Chart(NinthChart, {
// type: "bar",
// data: {
// datasets: [
// {
// data: [
// -50,
// -80,
// ],
// backgroundColor: [
// chartColors[4],
// chartColors[5],
// ],
// label: "hey"
// },
// {
// data: [
// 91,
// 19,
// ],
// backgroundColor: [
// chartColors[6],
// chartColors[7],
// ],
// label: "hey"
// },
// ],
// labels: [
// "",
// "",
// ],
// },
// options: {
// scales: {
// yAxes: [{
// stacked: true,
// ticks: {
// suggestedMin: 0,
// suggestedMax: 100
// }
// }],
// xAxes: [{
// stacked: true,
// ticks: {
// min: 0
// }
// }]
// },
// plugins: {
// datalabels: {
// anchor: "center",
// align: "center",
// offset: 10,
// color: "#fffff",
// },
// },
// responsive: true,
// legend: {
// display: false,
// position: "left",
// },
// title: {
// display: false,
// text: "تفکیک پروژه های راه روستایی",
// position: "bottom",
// },
// tooltips: {
// enabled: false,
// },
// },
// });
function init_province_filter() {
$.ajax({
url: "https://rms.rmto.ir/public/contents/provinces",
type: "GET",
success: function (data) {
list_province = data.data;
for (let index = 0; index < list_province.length; index++) {
$("#select-province").append(
"\
<option value=" +
list_province[index].id +
">" +
list_province[index].name_fa +
"</option>\
"
);
}
},
});
}
function init_town_filter() {
let hold_idSelect = $("#select-province").val();
//console.log("damad");
$.ajax({
url: "https://rms.rmto.ir/public/contents/provinces/" + hold_idSelect,
// hold_idSelect,
type: "GET",
success: function (data) {
list_citys = data.data;
//ppp
// $("#select-city1").val(0).trigger("change");
$("#select-city").html("");
for (let index = 0; index < list_citys.length; index++) {
$("#select-city").append(
"\
<option value=" +
list_citys[index].id +
">" +
list_citys[index].name_fa +
"</option>\
"
);
}
},
});
// if ($("#select-province1").val() != 0) {
// $(".btn-increase").prop("disabled", false);
// }
// $(".btn-increase").on("click", function () {
// $("#append-input-forFilter2").removeClass("d-none");
// });
}
$("#select-province").on("change", function () {
if ($("#select-province").val() != "0") {
init_town_filter();
selectedProvinceId = $("#select-province").val()
zoomMapToFeature(feaLayer[list_province[selectedProvinceId - 1].abrar_feature])
var province_id = $("#select-province").val();
//console.log(province_id);
$.ajax({
url: "https://rms.rmto.ir/api/milad?i=1&p=" + province_id,
type: "GET",
cache: false,
success: function (result) {
//console.log("apiRes",result);
resu = result;
// ShowBi(result);
},
error: function (error) {
//console.log(error);
},
});
}
});
frommDate = $("#dateFrom").persianDatepicker({
initialValueType: 'persian',
format: "YYYY/MM/DD",
maxDate: new persianDate().startOf('day'),
autoClose: true,
onSelect: function (unix) {
frommDate.touched = true;
$("#datepicktodate").prop("disabled", "");
if (
frommDate.getState().selected.unixDate >=
tooDate.getState().selected.unixDate
) {
tooDate.setDate(frommDate.getState().selected.unixDate);
}
if (tooDate && tooDate.options && tooDate.options.minDate != unix) {
let cachedValue = tooDate.getState().selected.unixDate;
tooDate.options = { minDate: unix };
if (tooDate.touched) {
tooDate.setDate(cachedValue);
}
}
},
});
// toDatekeshvari = $("#datepicktodateTestItems").persianDatepicker({
// format: "YYYY/MM/DD",
// autoClose: true,
// onSelect: function (unix) {
// toDateTestItems.touched = true;
// },
// });
// //console.log("2sob", persianDate().unix());
tooDate = $("#dateTo").persianDatepicker({
format: "YYYY/MM/DD",
maxDate: new persianDate().startOf('day'),
autoClose: true,
onSelect: function (unix) {
tooDate.touched = true;
/*if (fromDate && fromDate.options && fromDate.options.maxDate != unix) {
let cachedValue = fromDate.getState().selected.unixDate;
fromDate.options = { maxDate: unix };
if (fromDate.touched) {
fromDate.setDate(cachedValue);
}
}*/
},
});
// $.ajax({
// url: "https://192.168.1.75/rms_new/public/index.php/projects/ristat?end-date=2021-02-16&start-date=2020-11-21",
// type: "GET",
// cache: false,
// success: function (result) {
// //console.log("mosh moshi",result.data[0]);
// for(var i=1 ; i<18 ; i++){
// dataSix[i-1] = result.data[0]["item_"+i]
// }
// var SixthChart = document.getElementById("myChartSixth").getContext("2d");
// var myChartSixth = new Chart(SixthChart, {
// type: "horizontalBar",
// data: {
// datasets: [
// {
// data: dataSix
// // [
// // 711,
// // 605,
// // 511,
// // 309,
// // 220,
// // 198,
// // 178,
// // 136,
// // 135,
// // 134,
// // 118,
// // 109,
// // 97,
// // 87,
// // 65,
// // 45,
// // 55,
// // ]
// ,
// backgroundColor: [
// chartColors[0],
// chartColors[1],
// chartColors[2],
// chartColors[3],
// chartColors[4],
// chartColors[5],
// chartColors[6],
// chartColors[7],
// chartColors[8],
// chartColors[9],
// chartColors[10],
// chartColors[11],
// chartColors[12],
// chartColors[0],
// chartColors[1],
// chartColors[2],
// chartColors[4],
// ],
// label: ""
// },
// ],
// labels: [
// "مرمت رویه",
// "پاکسازی",
// "علائم",
// "حفاظ",
// "روشنایی",
// "خط کشی",
// "رنگ آمیزی",
// "شستشو",
// "ایمن سازی",
// "حریم",
// "پل",
// "تونل و گالری",
// "عملیات زمستانی",
// "ماشین آلات",
// "راهدارخانه",
// "موارد اضطراری",
// "آیتم های بازدید و بازرسی کنترل",
// ],
// },
// options: {
// onClick: (e) => {
// var sixPoint = myChartSixth.getElementAtEvent(e);
// if (sixPoint[0]) {
// //console.log("to ke dele",sixPoint[0]._index);
// var label = myChartSixth.data.labels[sixPoint[0]._index];
// var value = myChartSixth.data.datasets[0].data[sixPoint[0]._index];
// //console.log("roye mood ane 6");
// //console.log(label);
// //console.log(value);
// // xAxes: [{
// // ticks: {
// // display: false //this will remove only the label
// // }
// // }]
// }
// },
// scales: {
// yAxes: [{
// ticks: {
// display: false
// // suggestedMin: 0,
// // suggestedMax: 1017
// }
// }],
// xAxes: [{
// ticks: {
// min: 0
// }
// }]
// },
// plugins: {
// datalabels: {
// anchor: "center",
// align: "center",
// offset: 10,
// color: "#fffff",
// },
// },
// responsive: true,
// legend: {
// display: false,
// position: "left",
// },
// title: {
// display: false,
// text: "تفکیک پروژه های راه روستایی",
// position: "bottom",
// },
// tooltips: {
// enabled: true,
// },
// },
// });
// },
// error: function (error) {
// //console.log(error);
// },
// });
$("#submitDate").on("click", function () {
//console.log("hello");
let startDate = moment(
frommDate.getState().selected.year +
"/" +
frommDate.getState().selected.month +
"/" +
frommDate.getState().selected.date,
"jYYYY/jM/jD"
).format("YYYY-MM-DD");
let endDate = moment(
tooDate.getState().selected.year +
"/" +
tooDate.getState().selected.month +
"/" +
tooDate.getState().selected.date,
"jYYYY/jM/jD"
).format("YYYY-MM-DD");
//console.log("ijij","https://192.168.1.75/rms_new/public/index.php/projects/ristat"+ "?end-date=" + endDate + "&start-date=" + startDate);
$.ajax({
url: "https://192.168.1.75/rms_new/public/index.php/projects/ristat" + "?end-date=" + endDate + "&start-date=" + startDate,
type: "GET",
cache: false,
success: function (result) {
//console.log("mathew",result);
},
error: function (error) {
//console.log(error);
},
});
})
function sortObjectEntries(obj, n) {
let sortedList = []
//Sorting by values asc
sortedList = Object.entries(obj).sort((a, b) => {
if (b[1] > a[1]) return 1;
else if (b[1] < a[1]) return -1;
//if values are same do edition checking if keys are in the right order
else {
if (a[0] > b[0]) return 1;
else if (a[0] < b[0]) return -1;
else return 0
}
})
// return first n values from sortedList
return sortedList.map(el => el[0]).slice(0, n)
}
var SixthChart = document.getElementById("myChartSixth").getContext("2d");
myChartSixth = new Chart(SixthChart, {
type: "horizontalBar",
data: {
datasets: [
{
data: []
,
backgroundColor: [],
label: ""
},
],
labels: [],
},
options: {
onClick: (e) => {
var sixPoint = myChartSixth.getElementAtEvent(e);
if (sixPoint[0]) {
//console.log("to ke dele",sixPoint[0]._index);
var label = myChartSixth.data.labels[sixPoint[0]._index];
var value = myChartSixth.data.datasets[0].data[sixPoint[0]._index];
//console.log("roye mood ane 6");
//console.log(label);
//console.log(value);
// xAxes: [{
// ticks: {
// display: false //this will remove only the label
// }
// }]
}
},
scales: {
yAxes: [{
ticks: {
display: true
// suggestedMin: 0,
// suggestedMax: 1017
}
}],
xAxes: [{
ticks: {
min: 0
}
}]
},
plugins: {
datalabels: {
anchor: "center",
align: "center",
offset: 10,
color: "#fffff",
},
},
responsive: true,
legend: {
display: false,
position: "left",
},
title: {
display: false,
text: "تفکیک پروژه های راه روستایی",
position: "bottom",
},
tooltips: {
enabled: true,
},
},
});
function ShowBi(res) {
var typeData = res.rahdari;
var mapped = new Map();
mapped = res.pahne;
pahneArray = [];
sortable = [];
// = pahneArray.map(function(el, i) {
// return { index: i, value: el };
// })
// $.each(keshvari,function (key, value) {
// pahneArray.push(value);
// })
//console.log("erade" , mapped);
//console.log("era" , mapped[2]);
// var sortable = [];
var sortableVal = [];
var sortableProvince = []
for (var index in mapped) {
sortable.push([index, mapped[index], provincesArray[index - 1].name_fa]);
pahneArray.push(mapped[index]);
}
sortable.sort(function (a, b) {
return b[1] - a[1];
});
for (var index in sortable) {
sortableVal.push(sortable[index][1])
sortableProvince.push(sortable[index][2])
}
minOfPahne = parseInt(sortable[sortable.length - 1][1])
maxOfPahne = parseInt(sortable[0][1])
damaneh = maxOfPahne - minOfPahne
charak = Math.round(damaneh / 3)
console.log("sortable", sortable);
console.log("pahneArray", pahneArray);
console.log("min", minOfPahne);
console.log("max", maxOfPahne);
console.log("damaneh", damaneh);
console.log("charak", charak);
charakAval = minOfPahne + charak;
charakDovom = maxOfPahne - charak;
console.log("charakAval", charakAval);
console.log("charakDovom", charakDovom);
var sortableColor = []
var color;
for (var index in sortable) {
// //console.log("winakan" ,sortable[index][1]);
color = null;
if (sortable[index][1] <= charakAval) {
color = "#ff704d"
sortableColor.push("#ff704d")
} else if (sortable[index][1] < charakDovom) {
color = "#ffeda0";
sortableColor.push("#ffeda0")
} else {
color = "#66cc66";
sortableColor.push("#66cc66")
}
sortable[index]["clr"] = color
}
var new_pahne = sortable.sort(function (a, b) {
return a[0] - b[0];
});
$('.counter').each(function () {
//console.log("logi", $(this)[0].id );
var countTo;
if ($(this)[0].id == "counter1") {
countTo = res.counts.rahdari;
} else if ($(this)[0].id == "counter2") {
countTo = res.counts.items;
} else if ($(this)[0].id == "counter3") {
countTo = res.counts.patrols;
} else if ($(this)[0].id == "counter4") {
countTo = res.counts.observds.ok;
} else {
countTo = 2222;
}
// if($(this)[0].id == "counter1"){
// var countTo = typeData.count_all;
// }else{
// var countTo = 2222;
// }
var $this = $(this);
$({ countNum: $this.text() }).animate({
countNum: countTo
},
{
duration: 3000,
easing: 'linear',
step: function () {
$this.text(Math.floor(this.countNum));
},
complete: function () {
$this.text(this.countNum);
}
});
});
var jariChartSecond = document.getElementById("myChartJariSecond").getContext("2d");
myChartJariSecond = new Chart(jariChartSecond, {
type: "bar",
data: {
datasets: [
{
data: [
],
backgroundColor: [
],
}
],
labels: [
],
},
options: {
onClick: (e) => {
var secondPoint = myChartSecond.getElementAtEvent(e);
if (secondPoint[0]) {
var label = myChartSecond.data.labels[secondPoint[0]._index];
var value = myChartSecond.data.datasets[0].data[secondPoint[0]._index];
//console.log("roye mood ane 2");
//console.log(label);
//console.log(value);
}
},
scales: {
yAxes: [{
ticks: {
suggestedMin: 0,
suggestedMax: 1017
}
}],
xAxes: [{
ticks: {
display: false //this will remove only the label
}
}]
},
// plugins: {
// datalabels: {
// anchor: "center",
// align: "center",
// offset: 10,
// color: "#ff9999",
// },
// },
responsive: true,
// legend: {
// display: true,
// position: "right",
// rtl: true,
// labels: {
// boxWidth: 13
// }
// },
legend: {
display: false,
position: "left",
labels: {
boxWidth: 13
}
},
title: {
display: false,
text: "تفکیک پروژه های راه روستایی",
position: "bottom",
},
tooltips: {
enabled: true,
},
},
});
var chart23Chart = document.getElementById("chart23").getContext("2d");
myChart23 = new Chart(chart23Chart, {
type: "doughnut",
data: {
datasets: [
{
data: [
typeData.axis_type_count[1],
typeData.axis_type_count[2],
typeData.axis_type_count[3],
typeData.axis_type_count[4]
],
backgroundColor: [
chartColors[0],
chartColors[1],
chartColors[2],
chartColors[3],
// chartColors[4],
],
},
],
labels: [
"روستایی",
"فرعی",
"اصلی",
"شریانی",
],
},
options: {
onClick: (e) => {
//console.log("hello seven");
var sevenPoint = myChartSeventh.getElementAtEvent(e);
if (sevenPoint[0]) {
var label = myChartSeventh.data.labels[sevenPoint[0]._index];
var value = myChartSeventh.data.datasets[0].data[sevenPoint[0]._index];
//console.log("roye mood ane 7");
//console.log(label);
//console.log(value);
}
},
// scales: {
// yAxes: [{
// ticks: {
// suggestedMin: 0,
// suggestedMax: 1017
// }
// }]
// },
plugins: {
datalabels: {
anchor: "center",
align: "center",
offset: 10,
color: "#fffff",
},
},
responsive: true,
legend: {
display: false,
position: "left",
},
title: {
display: false,
text: "تفکیک پروژه های راه روستایی",
position: "bottom",
},
tooltips: {
enabled: true,
},
},
});
var FirstChart = document.getElementById("myChartfirst").getContext("2d");
var myChartFirst = new Chart(FirstChart, {
type: "bar",
data: {
datasets: [
{
data: [
typeData.counts.tollhouse_management_count,
typeData.counts.technical_building_count,
typeData.counts.upgrade_safety_count,
typeData.counts.danger_prevention_count,
typeData.counts.maintenance_project_count,
],
backgroundColor: [
chartColors[0],
chartColors[1],
chartColors[2],
chartColors[3],
chartColors[4],
],
},
],
labels: [
"راهدارخانه (بهسازی و نوسازی)",
"ابنیه فنی (نگهداری و ساخت )",
"ارتقای ایمنی راه ",
" رفع نقاط حادثه خیز / پرتصادف",
"روکش آسفالت (نگهداری راه )",
],
},
options: {
onClick: (e) => {
var firstPoint = myChartFirst.getElementAtEvent(e);
if (firstPoint[0]) {
var label = myChartFirst.data.labels[firstPoint[0]._index];
var value = myChartFirst.data.datasets[0].data[firstPoint[0]._index];
//console.log("roye mood ane");
//console.log(label);
//console.log(value);
}
},
scales: {
yAxes: [{
ticks: {
suggestedMin: 0,
suggestedMax: 1017
}
}],
xAxes: [{
ticks: {
display: false //this will remove only the label
}
}]
},
plugins: {
datalabels: {
anchor: "center",
align: "center",
offset: 10,
color: "#fffff",
},
},
responsive: true,
legend: {
display: false,
position: "left",
},
title: {
display: false,
text: "تفکیک پروژه های راه روستایی",
position: "bottom",
},
tooltips: {
enabled: true,
},
},
});
var SecondChart = document.getElementById("myChartSecond").getContext("2d");
var myChartSecond = new Chart(SecondChart, {
type: "bar",
data: {
datasets: [
{
data: [
typeData.project_status[8],
typeData.project_status[7],
typeData.project_status[6],
typeData.project_status[5],
typeData.project_status[4],
typeData.project_status[3],
typeData.project_status[2],
typeData.project_status[1],
typeData.project_status[0],
],
backgroundColor: [
chartColors[0],
chartColors[1],
chartColors[2],
chartColors[3],
chartColors[4],
chartColors[5],
chartColors[6],
chartColors[7],
chartColors[8],
],
}
],
labels: [
"تکمیل و خاتمه یافته و بهره برداری شده ",
"در حال آماده سازی برای افتتاح",
"در حال اجرا متوقف",
"در حال اجرا /فعال",
"در حال تجهیز کارگاه",
"در دست مناقصه",
"در دست مطالعه و تهیه اسناد مناقصه",
"در دست برنامه ریزی اولیه",
"توسط استان بروزرسانی نشده ",
],
},
options: {
onClick: (e) => {
var secondPoint = myChartSecond.getElementAtEvent(e);
if (secondPoint[0]) {
var label = myChartSecond.data.labels[secondPoint[0]._index];
var value = myChartSecond.data.datasets[0].data[secondPoint[0]._index];
//console.log("roye mood ane 2");
//console.log(label);
//console.log(value);
}
},
scales: {
yAxes: [{
ticks: {
suggestedMin: 0,
suggestedMax: 1017
}
}],
xAxes: [{
ticks: {
display: false //this will remove only the label
}
}]
},
// plugins: {
// datalabels: {
// anchor: "center",
// align: "center",
// offset: 10,
// color: "#ff9999",
// },
// },
responsive: true,
// legend: {
// display: true,
// position: "right",
// rtl: true,
// labels: {
// boxWidth: 13
// }
// },
legend: {
display: false,
position: "left",
labels: {
boxWidth: 13
}
},
title: {
display: false,
text: "تفکیک پروژه های راه روستایی",
position: "bottom",
},
tooltips: {
enabled: true,
},
},
});
changeChartData(myChartSixth, sortableVal, sortableColor, sortableProvince)
var SeventhChart = document.getElementById("myChartSeventh").getContext("2d");
var myChartSeventh = new Chart(SeventhChart, {
type: "doughnut",
data: {
datasets: [
{
data: [
typeData.axis_type_count[1],
typeData.axis_type_count[2],
typeData.axis_type_count[3],
typeData.axis_type_count[4]
],
backgroundColor: [
chartColors[0],
chartColors[1],
chartColors[2],
chartColors[3],
// chartColors[4],
],
},
],
labels: [
"روستایی",
"فرعی",
"اصلی",
"شریانی",
],
},
options: {
onClick: (e) => {
//console.log("hello seven");
var sevenPoint = myChartSeventh.getElementAtEvent(e);
if (sevenPoint[0]) {
var label = myChartSeventh.data.labels[sevenPoint[0]._index];
var value = myChartSeventh.data.datasets[0].data[sevenPoint[0]._index];
//console.log("roye mood ane 7");
//console.log(label);
//console.log(value);
}
},
// scales: {
// yAxes: [{
// ticks: {
// suggestedMin: 0,
// suggestedMax: 1017
// }
// }]
// },
plugins: {
datalabels: {
anchor: "center",
align: "center",
offset: 10,
color: "#fffff",
},
},
responsive: true,
legend: {
display: false,
position: "left",
},
title: {
display: false,
text: "تفکیک پروژه های راه روستایی",
position: "bottom",
},
tooltips: {
enabled: true,
},
},
});
rahdariPercent = typeData.avg[0].ag / 100;
bar.animate(rahdariPercent);
//console.log("moze",rahdariPercent);
removeFeaturesFromMap();
$.ajax({
url: "https://rms.rmto.ir/api/provinces35geojsonbi",
type: "GET",
success: function (response) {
iranGeoJSON = JSON.parse(response);
// setTimeout(() => {
iranMapGeo = L.geoJson(iranGeoJSON, {
style: initStyleMapFeatures,
onEachFeature: onEachFeature,
});
iranMapGeo.addTo(map);
// }, 2000);
},
});
$.ajax({
url: "https://141.ir/api/cities430geojson",
type: "GET",
success: function (response) {
fullCityGeoJSON = JSON.parse(response);
},
});
}
function ShowBiO(res) {
var pahne = res.pahne
pahneArray = []
sortable2 = pahne;
var sortableVal = [];
var sortableProvince = []
console.log("yani chi", sortable2);
for (var i = 0; i < pahne.length; i++) {
// console.log("koko", pahne[i]);
pahne[i].province_name = provincesArray[i].name_fa;
pahneArray.push(pahne[i]["total"]);
}
// pahne.forEach( function (element , index) {
// console.log("elementor" , element);
// element.province_name = provincesArray[index-1].name_fa;
// pahneArray.push(element["total"]);
// });
sortable2.sort(function (a, b) {
return b["total"] - a["total"];
});
console.log("kiffff", sortable2);
for (var index in sortable2) {
sortableVal.push(sortable2[index]["total"])
sortableProvince.push(sortable2[index]["province_name"])
}
minOfPahne = parseInt(sortable2[sortable2.length - 1]["total"])
maxOfPahne = parseInt(sortable2[0]["total"])
damaneh = maxOfPahne - minOfPahne
charak = Math.round(damaneh / 3)
// console.log("min" , minOfPahne);
// console.log("max" , maxOfPahne);
// console.log("damaneh" , damaneh);
// console.log("charak" , charak);
charakAval = minOfPahne + charak;
charakDovom = maxOfPahne - charak;
console.log("charakAval", charakAval);
console.log("charakDovom", charakDovom);
var sortableColor = []
var color;
for (var index in sortable2) {
// //console.log("winakan" ,sortable[index][1]);
color = null;
if (sortable2[index]["total"] <= charakAval) {
// color = "#ff704d"
sortableColor.push("#ff704d")
} else if (sortable2[index]["total"] < charakDovom) {
// color = "#ffeda0";
sortableColor.push("#ffeda0")
} else {
// color = "#66cc66";
sortableColor.push("#66cc66")
}
// sortable2[index]["clr"] = color
}
var new_pahne = sortable.sort(function (a, b) {
return a[0] - b[0];
});
$('.counter').each(function () {
//console.log("logi", $(this)[0].id );
var countTo;
if ($(this)[0].id == "counter1") {
countTo = res.counts.rahdari;
} else if ($(this)[0].id == "counter2") {
countTo = res.counts.items;
} else if ($(this)[0].id == "counter3") {
countTo = res.counts.patrols;
} else if ($(this)[0].id == "counter4") {
countTo = res.counts.observds.ok;
} else {
var countTo = 2222;
}
var $this = $(this);
$({ countNum: $this.text() }).animate({
countNum: countTo
},
{
duration: 3000,
easing: 'linear',
step: function () {
$this.text(Math.floor(this.countNum));
},
complete: function () {
$this.text(this.countNum);
}
});
});
changeChartData(myChartSixth, sortableVal, sortableColor, sortableProvince)
// var jariChart = document.getElementById("myChartJari").getContext("2d");
// var myChartJari = new Chart(jariChart, {
// type: "doughnut",
// data: {
// datasets: [
// {
// data: [
// 1944,
// 1392,
// 788,
// 1141
// ],
// backgroundColor: [
// chartColors[0],
// chartColors[1],
// chartColors[2],
// chartColors[3],
// // chartColors[4],
// ],
// },
// ],
// labels: [
// "روستایی",
// "فرعی",
// "اصلی",
// "شریانی",
// ],
// },
// options: {
// onClick: (e) => {
// //console.log("hello seven");
// var sevenPoint = myChartSeventh.getElementAtEvent(e);
// if (sevenPoint[0]) {
// var label = myChartSeventh.data.labels[sevenPoint[0]._index];
// var value = myChartSeventh.data.datasets[0].data[sevenPoint[0]._index];
// //console.log("roye mood ane 7");
// //console.log(label);
// //console.log(value);
// }
// },
// // scales: {
// // yAxes: [{
// // ticks: {
// // suggestedMin: 0,
// // suggestedMax: 1017
// // }
// // }]
// // },
// plugins: {
// datalabels: {
// anchor: "center",
// align: "center",
// offset: 10,
// color: "#fffff",
// },
// },
// responsive: true,
// legend: {
// display: false,
// position: "left",
// },
// title: {
// display: false,
// text: "تفکیک پروژه های راه روستایی",
// position: "bottom",
// },
// tooltips: {
// enabled: true,
// },
// },
// });
// var jariChartSecond = document.getElementById("myChartJariSecond").getContext("2d");
// var myChartJariSecond = new Chart(jariChartSecond, {
// type: "bar",
// data: {
// datasets: [
// {
// data: [
// 1920,
// 508,
// 210,
// 1100,
// 1425,
// 250,
// 720,
// 1850,
// 740,
// ],
// backgroundColor: [
// chartColors[0],
// chartColors[1],
// chartColors[2],
// chartColors[3],
// chartColors[4],
// chartColors[5],
// chartColors[6],
// chartColors[7],
// chartColors[8],
// ],
// }
// ],
// labels: [
// "تکمیل و خاتمه یافته و بهره برداری شده ",
// "در حال آماده سازی برای افتتاح",
// "در حال اجرا متوقف",
// "در حال اجرا /فعال",
// "در حال تجهیز کارگاه",
// "در دست مناقصه",
// "در دست مطالعه و تهیه اسناد مناقصه",
// "در دست برنامه ریزی اولیه",
// "توسط استان بروزرسانی نشده ",
// ],
// },
// options: {
// onClick: (e) => {
// var secondPoint = myChartSecond.getElementAtEvent(e);
// if (secondPoint[0]) {
// var label = myChartSecond.data.labels[secondPoint[0]._index];
// var value = myChartSecond.data.datasets[0].data[secondPoint[0]._index];
// //console.log("roye mood ane 2");
// //console.log(label);
// //console.log(value);
// }
// },
// scales: {
// yAxes: [{
// ticks: {
// suggestedMin: 0,
// suggestedMax: 1017
// }
// }],
// xAxes: [{
// ticks: {
// display: false //this will remove only the label
// }
// }]
// },
// // plugins: {
// // datalabels: {
// // anchor: "center",
// // align: "center",
// // offset: 10,
// // color: "#ff9999",
// // },
// // },
// responsive: true,
// // legend: {
// // display: true,
// // position: "right",
// // rtl: true,
// // labels: {
// // boxWidth: 13
// // }
// // },
// legend: {
// display: false,
// position: "left",
// labels: {
// boxWidth: 13
// }
// },
// title: {
// display: false,
// text: "تفکیک پروژه های راه روستایی",
// position: "bottom",
// },
// tooltips: {
// enabled: true,
// },
// },
// });
// rahdariPercent = typeData.avg[0].ag/100;
// bar.animate(rahdariPercent);
//console.log("moze",rahdariPercent);
removeFeaturesFromMap();
iranArrayCount = 0;
$.ajax({
url: "https://rms.rmto.ir/api/provinces35geojsonbi",
type: "GET",
success: function (response) {
iranGeoJSON = JSON.parse(response);
// setTimeout(() => {
iranMapGeo = L.geoJson(iranGeoJSON, {
style: initStyleMapFeatures,
onEachFeature: onEachFeature,
});
iranMapGeo.addTo(map);
// }, 2000);
},
});
$.ajax({
url: "https://141.ir/api/cities430geojson",
type: "GET",
success: function (response) {
fullCityGeoJSON = JSON.parse(response);
},
});
}
function ShowBiS(res) {
var pahne = res.pahne
pahneArray = []
sortable2 = pahne;
var sortableVal = [];
var sortableProvince = []
// console.log("yani chi" , provincesArray);
for (var i = 0; i < pahne.length; i++) {
if (indexCol == 1) {
pahneArray.push(pahne[i]["cnt"]);
} else {
pahneArray.push(pahne[i]["total"]);
}
}
// pahne.forEach( function (element , index) {
// console.log("elementor" , element);
// element.province_name = provincesArray[index-1].name_fa;
// pahneArray.push(element["total"]);
// });
if (indexCol == 1) {
sortable2.sort(function (a, b) {
return b["cnt"] - a["cnt"];
});
} else {
sortable2.sort(function (a, b) {
return b["total"] - a["total"];
});
}
console.log("kiffff", sortable2);
for (var index in sortable2) {
if (indexCol == 1) {
sortableVal.push(sortable2[index]["cnt"])
} else {
sortableVal.push(sortable2[index]["total"])
}
sortableProvince.push(sortable2[index]["city_fa"])
}
if (indexCol == 1) {
minOfPahne = parseInt(sortable2[sortable2.length - 1]["cnt"])
maxOfPahne = parseInt(sortable2[0]["cnt"])
} else {
minOfPahne = parseInt(sortable2[sortable2.length - 1]["total"])
maxOfPahne = parseInt(sortable2[0]["total"])
}
damaneh = maxOfPahne - minOfPahne
charak = Math.round(damaneh / 3)
console.log("min", minOfPahne);
console.log("max", maxOfPahne);
console.log("damaneh", damaneh);
console.log("charak", charak);
charakAval = minOfPahne + charak;
charakDovom = maxOfPahne - charak;
console.log("charakAval", charakAval);
console.log("charakDovom", charakDovom);
var sortableColor = []
var color;
for (var index in sortable2) {
// //console.log("winakan" ,sortable[index][1]);
color = null;
if (indexCol == 1) {
if (sortable2[index]["cnt"] <= charakAval) {
// color = "#ff704d"
sortableColor.push("#ff704d")
} else if (sortable2[index]["cnt"] < charakDovom) {
// color = "#ffeda0";
sortableColor.push("#ffeda0")
} else {
// color = "#66cc66";
sortableColor.push("#66cc66")
}
} else {
if (sortable2[index]["total"] <= charakAval) {
// color = "#ff704d"
sortableColor.push("#ff704d")
} else if (sortable2[index]["total"] < charakDovom) {
// color = "#ffeda0";
sortableColor.push("#ffeda0")
} else {
// color = "#66cc66";
sortableColor.push("#66cc66")
}
}
// sortable2[index]["clr"] = color
}
var new_pahne = sortable.sort(function (a, b) {
return a[0] - b[0];
});
$('.counter').each(function () {
//console.log("logi", $(this)[0].id );
var countTo;
if ($(this)[0].id == "counter1") {
countTo = res.counts.rahdari;
} else if ($(this)[0].id == "counter2") {
countTo = res.counts.items;
} else if ($(this)[0].id == "counter3") {
countTo = res.counts.patrols;
} else if ($(this)[0].id == "counter4") {
countTo = res.counts.observds.ok;
} else {
var countTo = 2222;
}
var $this = $(this);
$({ countNum: $this.text() }).animate({
countNum: countTo
},
{
duration: 3000,
easing: 'linear',
step: function () {
$this.text(Math.floor(this.countNum));
},
complete: function () {
$this.text(this.countNum);
}
});
});
changeChartData(myChartSixth, sortableVal, sortableColor, sortableProvince)
// var jariChart = document.getElementById("myChartJari").getContext("2d");
// var myChartJari = new Chart(jariChart, {
// type: "doughnut",
// data: {
// datasets: [
// {
// data: [
// 1944,
// 1392,
// 788,
// 1141
// ],
// backgroundColor: [
// chartColors[0],
// chartColors[1],
// chartColors[2],
// chartColors[3],
// // chartColors[4],
// ],
// },
// ],
// labels: [
// "روستایی",
// "فرعی",
// "اصلی",
// "شریانی",
// ],
// },
// options: {
// onClick: (e) => {
// //console.log("hello seven");
// var sevenPoint = myChartSeventh.getElementAtEvent(e);
// if (sevenPoint[0]) {
// var label = myChartSeventh.data.labels[sevenPoint[0]._index];
// var value = myChartSeventh.data.datasets[0].data[sevenPoint[0]._index];
// //console.log("roye mood ane 7");
// //console.log(label);
// //console.log(value);
// }
// },
// // scales: {
// // yAxes: [{
// // ticks: {
// // suggestedMin: 0,
// // suggestedMax: 1017
// // }
// // }]
// // },
// plugins: {
// datalabels: {
// anchor: "center",
// align: "center",
// offset: 10,
// color: "#fffff",
// },
// },
// responsive: true,
// legend: {
// display: false,
// position: "left",
// },
// title: {
// display: false,
// text: "تفکیک پروژه های راه روستایی",
// position: "bottom",
// },
// tooltips: {
// enabled: true,
// },
// },
// });
// var jariChartSecond = document.getElementById("myChartJariSecond").getContext("2d");
// var myChartJariSecond = new Chart(jariChartSecond, {
// type: "bar",
// data: {
// datasets: [
// {
// data: [
// 1920,
// 508,
// 210,
// 1100,
// 1425,
// 250,
// 720,
// 1850,
// 740,
// ],
// backgroundColor: [
// chartColors[0],
// chartColors[1],
// chartColors[2],
// chartColors[3],
// chartColors[4],
// chartColors[5],
// chartColors[6],
// chartColors[7],
// chartColors[8],
// ],
// }
// ],
// labels: [
// "تکمیل و خاتمه یافته و بهره برداری شده ",
// "در حال آماده سازی برای افتتاح",
// "در حال اجرا متوقف",
// "در حال اجرا /فعال",
// "در حال تجهیز کارگاه",
// "در دست مناقصه",
// "در دست مطالعه و تهیه اسناد مناقصه",
// "در دست برنامه ریزی اولیه",
// "توسط استان بروزرسانی نشده ",
// ],
// },
// options: {
// onClick: (e) => {
// var secondPoint = myChartSecond.getElementAtEvent(e);
// if (secondPoint[0]) {
// var label = myChartSecond.data.labels[secondPoint[0]._index];
// var value = myChartSecond.data.datasets[0].data[secondPoint[0]._index];
// //console.log("roye mood ane 2");
// //console.log(label);
// //console.log(value);
// }
// },
// scales: {
// yAxes: [{
// ticks: {
// suggestedMin: 0,
// suggestedMax: 1017
// }
// }],
// xAxes: [{
// ticks: {
// display: false //this will remove only the label
// }
// }]
// },
// // plugins: {
// // datalabels: {
// // anchor: "center",
// // align: "center",
// // offset: 10,
// // color: "#ff9999",
// // },
// // },
// responsive: true,
// // legend: {
// // display: true,
// // position: "right",
// // rtl: true,
// // labels: {
// // boxWidth: 13
// // }
// // },
// legend: {
// display: false,
// position: "left",
// labels: {
// boxWidth: 13
// }
// },
// title: {
// display: false,
// text: "تفکیک پروژه های راه روستایی",
// position: "bottom",
// },
// tooltips: {
// enabled: true,
// },
// },
// });
// rahdariPercent = typeData.avg[0].ag/100;
// bar.animate(rahdariPercent);
//console.log("moze",rahdariPercent);
removeFeaturesFromMap();
iranArrayCount = 0;
// $.ajax({
// url: "https://rms.rmto.ir/api/provinces35geojsonbi",
// type: "GET",
// success: function (response) {
// iranGeoJSON = JSON.parse(response);
// // setTimeout(() => {
// iranMapGeo = L.geoJson(iranGeoJSON, {
// style: initStyleMapFeatures,
// onEachFeature: onEachFeature,
// });
// iranMapGeo.addTo(map);
// // }, 2000);
// },
// });
$.ajax({
url: "https://141.ir/api/cities430geojson",
type: "GET",
success: function (response) {
fullCityGeoJSON = JSON.parse(response);
},
});
}
function showProgressBar() {
$("#modalCenter .modal-body").empty();
$("#exampleModalLongTitle").html("پیشرفت فیزیکی کل پروژه ها")
$("#modalCenter .modal-body").append(`<div id="progressBarModal"></div>`);
var progressBar = document.getElementById("progressBarModal")
var bar = new ProgressBar.SemiCircle(progressBar, {
strokeWidth: 20,
color: '#FFEA82',
trailColor: '#FFEA82',
trailWidth: 20,
easing: 'easeInOut',
duration: 1400,
svgStyle: null,
text: {
value: '',
alignToBottom: false
},
from: { color: '#FFEA82' },
to: { color: '#ED6A5A' },
// Set default step function for all animate calls
step: (state, bar) => {
bar.path.setAttribute('stroke', state.color);
var value = Math.round(bar.value() * 100);
if (value === 0) {
bar.setText('');
} else {
bar.setText(value);
}
bar.text.style.color = state.color;
}
});
bar.text.style.fontFamily = '"Raleway", Helvetica, sans-serif';
bar.text.style.fontSize = '5rem';
bar.animate(0.67); // Number from 0.0 to 1.0
$('#modalCenter').modal('show')
}
function showFirstChModal() {
// $('#modalCenter .modal-body').append($("#myChartfirst").clone())
// $("#myChartfirst").clone().appendTo('#modalCenter .modal-body');
$("#exampleModalLongTitle").html("پروژه های راهداری به تفکیک")
$("#modalCenter .modal-body").empty();
$("#modalCenter .modal-body").append(`<canvas id="myChartfirstModal" class="chartjs-render-monitor"
style="display: block; height: 235px; width: 470px;" height="200"
width="587"></canvas>`);
var FirstChart = document.getElementById("myChartfirstModal").getContext("2d");
var myChartFirst = new Chart(FirstChart, {
type: "bar",
data: {
datasets: [
{
label: "راهدارخانه (بهسازی و نوسازی)",
data:
[resu.counts.tollhouse_management_count],
backgroundColor:
chartColors[0],
},
{
label: "ابنیه فنی (نگهداری و ساخت )",
data:
[resu.counts.technical_building_count],
backgroundColor:
chartColors[1],
},
{
label: "ارتقای ایمنی راه ",
data:
[resu.counts.upgrade_safety_count],
backgroundColor:
chartColors[2],
},
{
label: "رفع نقاط حادثه خیز / پرتصادف",
data:
[resu.counts.danger_prevention_count],
backgroundColor:
chartColors[3],
},
{
label: "روکش آسفالت (نگهداری راه )",
data:
[resu.counts.maintenance_project_count],
backgroundColor:
chartColors[4],
},
],
labels: "",
},
options: {
onClick: (e) => {
var firstPoint = myChartFirst.getElementAtEvent(e);
if (firstPoint[0]) {
var label = myChartFirst.data.labels[firstPoint[0]._index];
var value = myChartFirst.data.datasets[0].data[firstPoint[0]._index];
//console.log("roye mood ane");
//console.log(label);
//console.log(value);
}
},
scales: {
yAxes: [{
ticks: {
suggestedMin: 0,
suggestedMax: 1017
}
}],
xAxes: [{
ticks: {
display: false //this will remove only the label
}
}]
},
plugins: {
datalabels: {
anchor: "center",
align: "center",
offset: 10,
color: "#fffff",
},
},
responsive: true,
legend: {
display: true,
position: "left",
labels: {
boxWidth: 13
}
},
title: {
display: false,
text: "تفکیک پروژه های راه روستایی",
position: "bottom",
},
tooltips: {
enabled: true,
},
},
});
// //console.log("gireha",$("#myChartfirst"));
// //console.log("mireha",$("#myChartfirst").clone());
$('#modalCenter').modal('show')
}
function showSecondChModal() {
$("#modalCenter .modal-body").empty();
$("#exampleModalLongTitle").html("آخرین وضعیت پروژه ها")
$("#modalCenter .modal-body").append(`<canvas id="myChartSecondModal" class="chartjs-render-monitor"
style="display: block; height: 235px; width: 470px;" height="200"
width="587"></canvas>`);
var SecondChart = document.getElementById("myChartSecondModal").getContext("2d");
var myChartSecond = new Chart(SecondChart, {
type: "bar",
data: {
datasets: [
{
data: [
resu.project_status[8],
],
backgroundColor:
chartColors[0],
label: "تکمیل و خاتمه یافته و بهره برداری شده ",
},
{
data: [
resu.project_status[7],
],
backgroundColor:
chartColors[1],
label: "در حال آماده سازی برای افتتاح",
},
{
data: [
resu.project_status[6],
],
backgroundColor:
chartColors[2],
label: "در حال اجرا متوقف",
},
{
data: [
resu.project_status[5],
],
backgroundColor: chartColors[3],
label: "در حال اجرا /فعال",
},
{
data: [
resu.project_status[4],
],
backgroundColor: chartColors[4],
label: "در حال تجهیز کارگاه",
},
{
data: [
resu.project_status[3],
],
backgroundColor: chartColors[5],
label: "در دست مناقصه",
},
{
data: [
resu.project_status[2],
],
backgroundColor: chartColors[6],
label: "در دست مطالعه و تهیه اسناد مناقصه",
},
{
data: [
resu.project_status[1],
],
backgroundColor: chartColors[7],
label: "در دست برنامه ریزی اولیه",
},
{
data: [
resu.project_status[0],
],
backgroundColor:
chartColors[8],
label: "توسط استان بروزرسانی نشده ",
}
],
// labels: [
// ],
},
options: {
scales: {
yAxes: [{
ticks: {
suggestedMin: 0,
suggestedMax: 1017
}
}],
xAxes: [{
ticks: {
display: false //this will remove only the label
}
}]
},
// plugins: {
// datalabels: {
// anchor: "center",
// align: "center",
// offset: 10,
// color: "#ff9999",
// },
// },
responsive: true,
// legend: {
// display: true,
// position: "right",
// rtl: true,
// labels: {
// boxWidth: 13
// }
// },
legend: {
display: true,
position: "left",
labels: {
boxWidth: 13
}
},
title: {
display: false,
text: "تفکیک پروژه های راه روستایی",
position: "bottom",
},
tooltips: {
enabled: true,
},
},
});
$('#modalCenter').modal('show')
}
function showThirdChModal() {
$("#modalCenter .modal-body").empty();
$("#exampleModalLongTitle").html("استان با پیشرفت فیزیکی برتر")
$("#modalCenter .modal-body").append(` <canvas id="myChartThirdModal" class="chartjs-render-monitor"
style="display: block; height: 235px; width: 470px;" height="210"
width="587"></canvas>`);
var ThirdChart = document.getElementById("myChartThirdModal").getContext("2d");
var myChartThird = new Chart(ThirdChart, {
type: "horizontalBar",
data: {
datasets: [
{
data: [
100,
98,
87,
],
backgroundColor: [
chartColors[0],
chartColors[1],
chartColors[2],
],
label: "hey"
},
],
labels: [
"",
"",
"",
],
},
options: {
scales: {
yAxes: [{
ticks: {
suggestedMin: 0,
suggestedMax: 1017
}
}],
xAxes: [{
ticks: {
min: 0
}
}]
},
plugins: {
datalabels: {
anchor: "center",
align: "center",
offset: 10,
color: "#fffff",
},
},
responsive: true,
legend: {
display: false,
position: "left",
},
title: {
display: false,
text: "تفکیک پروژه های راه روستایی",
position: "bottom",
},
tooltips: {
enabled: false,
},
},
});
$('#modalCenter').modal('show')
}
function showForthChModal() {
$("#modalCenter .modal-body").empty();
$("#exampleModalLongTitle").html("ماموریت روزانه")
$("#modalCenter .modal-body").append(`<canvas id="myChartForthModal" class="chartjs-render-monitor"
style="display: block; height: 235px; width: 470px;" height="100"
width="587"></canvas>`);
var ForthChart = document.getElementById("myChartForthModal").getContext("2d");
var myChartForth = new Chart(ForthChart, {
type: "horizontalBar",
data: {
datasets: [
{
data: [
127,
110,
95,
],
backgroundColor: [
chartColors[0],
chartColors[1],
chartColors[2],
],
label: "hey"
},
],
labels: [
"",
"",
"",
],
},
options: {
scales: {
yAxes: [{
ticks: {
suggestedMin: 0,
suggestedMax: 1017
}
}],
xAxes: [{
ticks: {
min: 0
}
}]
},
plugins: {
datalabels: {
anchor: "center",
align: "center",
offset: 10,
color: "#fffff",
},
},
responsive: true,
legend: {
display: false,
position: "left",
},
title: {
display: false,
text: "تفکیک پروژه های راه روستایی",
position: "bottom",
},
tooltips: {
enabled: false,
},
},
});
$('#modalCenter').modal('show');
}
function showFifthChModal() {
$("#modalCenter .modal-body").empty();
$("#exampleModalLongTitle").html("آخرین وضعیت محور های مسدودی و آسیب دیده")
$("#modalCenter .modal-body").append(`<canvas id="myChartFifthModal" class="chartjs-render-monitor"
style="display: block; height: 235px; width: 470px;" height="260"
width="587"></canvas>`);
var FifthChart = document.getElementById("myChartFifthModal").getContext("2d");
var myChartFifth = new Chart(FifthChart, {
type: "bar",
data: {
datasets: [
{
data: [
127,
110,
95,
],
backgroundColor: [
chartColors[0],
chartColors[1],
chartColors[2],
],
label: "hey"
},
{
data: [
127,
110,
95,
],
backgroundColor: [
chartColors[3],
chartColors[4],
chartColors[5],
],
label: "hey"
},
{
data: [
127,
110,
95,
],
backgroundColor: [
chartColors[6],
chartColors[7],
chartColors[8],
],
label: "hey"
},
{
data: [
127,
110,
95,
],
backgroundColor: [
chartColors[9],
chartColors[10],
chartColors[11],
],
label: "hey"
},
],
labels: [
"",
"",
"",
],
},
options: {
scales: {
yAxes: [{
stacked: true,
ticks: {
suggestedMin: 0,
suggestedMax: 1017
}
}],
xAxes: [{
stacked: true,
ticks: {
min: 0
}
}]
},
plugins: {
datalabels: {
anchor: "center",
align: "center",
offset: 10,
color: "#fffff",
},
},
responsive: true,
legend: {
display: false,
position: "left",
},
title: {
display: false,
text: "تفکیک پروژه های راه روستایی",
position: "bottom",
},
tooltips: {
enabled: false,
},
},
});
$('#modalCenter').modal('show')
}
function showSixthChModal() {
$("#modalCenter .modal-body").empty();
$("#exampleModalLongTitle").html("فعالیت های روزانه")
$("#modalCenter .modal-body").append(`<canvas id="myChartSixthModal" class="chartjs-render-monitor"
style="display: block; height: 235px; width: 470px;" height="230vh"
width="587vw"></canvas>`);
var SixthChart = document.getElementById("myChartSixthModal").getContext("2d");
var myChartSixth = new Chart(SixthChart, {
type: "horizontalBar",
data: {
datasets: [
{
data: [
711,
605,
511,
309,
220,
198,
178,
136,
135,
134,
118,
109,
97,
87,
65,
45,
],
backgroundColor: [
chartColors[0],
chartColors[1],
chartColors[2],
chartColors[3],
chartColors[4],
chartColors[5],
chartColors[6],
chartColors[7],
chartColors[8],
chartColors[9],
chartColors[10],
chartColors[11],
chartColors[12],
chartColors[0],
chartColors[1],
chartColors[2],
],
label: "hey"
},
],
labels: [
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
],
},
options: {
scales: {
yAxes: [{
ticks: {
suggestedMin: 0,
suggestedMax: 1017
}
}],
xAxes: [{
ticks: {
min: 0
}
}]
},
plugins: {
datalabels: {
anchor: "center",
align: "center",
offset: 10,
color: "#fffff",
},
},
responsive: true,
legend: {
display: false,
position: "left",
},
title: {
display: false,
text: "تفکیک پروژه های راه روستایی",
position: "bottom",
},
tooltips: {
enabled: false,
},
},
});
$('#modalCenter').modal('show')
}
function showSeventhChModal() {
$("#modalCenter .modal-body").empty();
$("#exampleModalLongTitle").html("فعالیت های روزانه به تفکیک زیرآیتم")
$("#modalCenter .modal-body").append(`<canvas id="myChartSeventhModal" class="chartjs-render-monitor"
style="display: block; height: 235px; width: 470px;" height="230vh"
width="587vw"></canvas>`);
var SeventhChart = document.getElementById("myChartSeventhModal").getContext("2d");
var myChartSeventh = new Chart(SeventhChart, {
type: "doughnut",
data: {
datasets: [
{
data: [
311,
1211,
609,
514,
1017,
],
backgroundColor: [
chartColors[0],
chartColors[1],
chartColors[2],
chartColors[3],
chartColors[4],
],
},
],
labels: [
"راهدارخانه (بهسازی و نوسازی)",
"ابنیه فنی (نگهداری و ساخت )",
"رفع نقاط حادثه خیز / پرتصادف",
"ارتقای ایمنی راه ",
"روکش آسفالت (نگهداری راه )",
],
},
options: {
// scales: {
// yAxes: [{
// ticks: {
// suggestedMin: 0,
// suggestedMax: 1017
// }
// }]
// },
plugins: {
datalabels: {
anchor: "center",
align: "center",
offset: 10,
color: "#fffff",
},
},
responsive: true,
legend: {
display: true,
position: "left",
},
title: {
display: false,
text: "تفکیک پروژه های راه روستایی",
position: "bottom",
},
tooltips: {
enabled: true,
},
},
});
$('#modalCenter').modal('show')
}
function showEightNinthChModal() {
$("#modalCenter .modal-body").empty();
$("#exampleModalLongTitle").html("استان برتر و استان ضعیف در رسیدگی به شکایات")
$("#modalCenter .modal-body").append(`<canvas id="myChartEighthModal" class="chartjs-render-monitor"
style="display: block; height: 235px; width: 470px;"
height="300" width="587"></canvas>`);
$("#modalCenter .modal-body").append(`<canvas id="myChartNinthModal" class="chartjs-render-monitor"
style="display: block; height: 235px; width: 470px;" height="300"
width="587"></canvas>`);
var EighthChart = document.getElementById("myChartEighthModal").getContext("2d");
var myChartEighth = new Chart(EighthChart, {
type: "bar",
data: {
datasets: [
{
data: [
-16,
-30, 60,
],
backgroundColor: [
chartColors[0],
chartColors[1],
],
label: "hey"
},
{
data: [
127,
110,
],
backgroundColor: [
chartColors[2],
chartColors[3],
],
label: "hey"
},
],
labels: [
"",
"",
],
},
options: {
scales: {
yAxes: [{
stacked: true,
ticks: {
suggestedMin: 0,
suggestedMax: 100
}
}],
xAxes: [{
stacked: true,
ticks: {
min: 0
}
}]
},
plugins: {
datalabels: {
anchor: "center",
align: "center",
offset: 10,
color: "#fffff",
},
},
responsive: true,
legend: {
display: false,
position: "left",
},
title: {
display: false,
text: "تفکیک پروژه های راه روستایی",
position: "bottom",
},
tooltips: {
enabled: false,
},
},
});
var NinthChart = document.getElementById("myChartNinthModal").getContext("2d");
var myChartNinth = new Chart(NinthChart, {
type: "bar",
data: {
datasets: [
{
data: [
-50,
-80,
],
backgroundColor: [
chartColors[4],
chartColors[5],
],
label: "hey"
},
{
data: [
91,
19,
],
backgroundColor: [
chartColors[6],
chartColors[7],
],
label: "hey"
},
],
labels: [
"",
"",
],
},
options: {
scales: {
yAxes: [{
stacked: true,
ticks: {
suggestedMin: 0,
suggestedMax: 100
}
}],
xAxes: [{
stacked: true,
ticks: {
min: 0
}
}]
},
plugins: {
datalabels: {
anchor: "center",
align: "center",
offset: 10,
color: "#fffff",
},
},
responsive: true,
legend: {
display: false,
position: "left",
},
title: {
display: false,
text: "تفکیک پروژه های راه روستایی",
position: "bottom",
},
tooltips: {
enabled: false,
},
},
});
$('#modalCenter').modal('show')
}
function showFirstMapModal() {
$("#mapModalCenter .modal-body").empty();
$("#mapModalCenter .modal-body").append(`<div class="map-box">
<div id="map4" class="map4"></div>
<div hidden id="layer-spinner" class="spinner"></div>
</div>`)
$('#mapModalCenter').modal('show')
setTimeout(() => {
var map4 = L.map("map4", {
maxBounds: bounds,
minZoom: MAP_MIN_ZOOM,
//maxZoom: MAP_MAX_ZOOM,
zoomControl: false,
}).setView([32.4279, 53.6880], 4.2);
L.tileLayer(MAP_ENDPOINT + "/141map/{z}/{x}/{y}.png", {}).addTo(map4);
function addCityFeaturesToMap() {
console.log(fullCityGeoJSONTemp)
keepMapFeatureColor = null;
if (fullCityGeoJSONTemp) {
iranCityMapGeo = L.geoJson(fullCityGeoJSONTemp, {
style: initStyleCityMapFeatures,
onEachFeature: onEachCityFeature,
});
iranCityMapGeo.addTo(map4);
}
}
function getForArrayFeatureColor(arrayNum) {
if (keepMapFeatureColor) {
return { num: -1, color: keepMapFeatureColor };
} else {
return arrayNum >= 83
? { num: arrayNum, color: "#a366ff" }
: arrayNum >= 67
? { num: arrayNum, color: "#80b3ff" }
: arrayNum >= 50
? { num: arrayNum, color: "#66cc66" }
: arrayNum >= 31
? { num: arrayNum, color: "#ffeda0" }
: { num: arrayNum, color: "#ff704d" };
}
}
function fillcolorme(featureRow) {
for (let i = 0; i < provincesArray.length; i++) {
if (i == featureRow) {
return provincesArray[i].abrar_process;
}
}
}
function initStyleMapFeatures() {
let getRandom = null;
getRandom = getForArrayFeatureColor(fillcolorme(iranArrayCount));
let makeStyle = {
fillColor: getRandom.color,
weight: 2,
opacity: 1,
color: "white",
fillOpacity: 0.7,
};
if (getRandom.num != -1) {
if (iranArrayCount == 35) {
iranArrayCount = 0;
}
iranArrayCount++;
}
return makeStyle;
}
function highlightMapFeature(e) {
let targetAtt = e.target.feature.properties;
let featureLayer = null;
if (e.target) {
featureLayer = e.target;
} else {
featureLayer = e;
}
keepMapFeatureColor = featureLayer.options.fillColor;
featureLayer.setStyle({
weight: 4,
color: "#666",
fillOpacity: 0.85,
});
if (!L.Browser.ie && !L.Browser.opera && !L.Browser.edge) {
featureLayer.bringToFront();
}
}
function resetMapFeatureHighlight(e) {
let targetAtt = e.target.feature.properties;
let featureLayer = null;
if (e.target) {
featureLayer = e.target;
} else {
featureLayer = e;
}
iranMapGeo.resetStyle(featureLayer);
keepMapFeatureColor = null;
}
// function zoomMapToFeature(e) {
// removeFeaturesCity();
// if (e.target) {
// $.ajax({
// url: "https://rms.rmto.ir/public/contents/provinces/" +
// e.target.feature.properties.province_id,
// type: "GET",
// cache: false,
// contentType: false,
// processData: false,
// success: function (result) {
// citiesArray = result.data;
// },
// error: function (error) { },
// });
// } else {
// $.ajax({
// url: "https://rms.rmto.ir/public/contents/provinces/" +
// e.feature.properties.province_id,
// type: "GET",
// cache: false,
// contentType: false,
// processData: false,
// success: function (result) {
// citiesArray = result.data;
// },
// error: function (error) { },
// });
// }
// let featureLayer = null;
// let featuresLayerCity = [];
// if (e.target) {
// featureLayer = e.target;
// } else {
// featureLayer = e;
// }
// removeFeaturesFromMap();
// map4.flyToBounds(featureLayer.getBounds());
// // showLoaderScreen();
// // removeCityFeaturesFromMap();
// fullCityGeoJSONTemp.type = "FeatureCollection";
// $.each(fullCityGeoJSON.features, function (key, value) {
// if (
// value &&
// featureLayer.feature.properties.province_id ===
// value.properties.province_id
// ) {
// featuresLayerCity.push(value);
// } else {
// //
// }
// });
// setTimeout(function () {
// //todo pooria
// fullCityGeoJSONTemp.features = featuresLayerCity;
// for (let i = 0; i < fullCityGeoJSONTemp.features.length; i++) {
// for (let j = 0; j < citiesArray.length; j++) {
// if (
// fullCityGeoJSONTemp.features[i].properties.city_id ==
// citiesArray[j].id
// ) {
// fullCityGeoJSONTemp.features[i].properties["abrar_process"] =
// citiesArray[j].abrar_process;
// }
// }
// }
// addCityFeaturesToMap();
// }, 1000);
// setTimeout(function () {
// // hideLoaderScreen();
// }, 1500);
// flagProvince = 1;
// iranCityCount = 0;
// }
$(".backStack").on("click", function () {
removeFeaturesCity();
});
function onEachFeature(feature, featureLayer) {
feaLayer.push(featureLayer);
featureLayer.on({
mouseover: highlightMapFeature,
mouseout: resetMapFeatureHighlight,
click: zoomMapToFeature,
});
}
function onEachCityFeature(feature, featureLayer) {
featureLayer.on({
mouseover: highlightMapFeature,
mouseout: resetMapFeatureHighlight,
//click: zoomMapToFeature
});
}
function getRandomFeatureColor(arrayNum) {
if (keepMapFeatureColor) {
return { num: -1, color: keepMapFeatureColor };
} else {
return arrayNum.abrar_process >= 83
? { num: arrayNum, color: "#a366ff" }
: arrayNum.abrar_process >= 67
? { num: arrayNum, color: "#80b3ff" }
: arrayNum.abrar_process >= 50
? { num: arrayNum, color: "#66cc66" }
: arrayNum.abrar_process >= 31
? { num: arrayNum, color: "#ffeda0" }
: { num: arrayNum, color: "#ff704d" };
}
}
function fillcolorCity(featureRow) {
// //console.log(featureRow);
for (let i = 0; i < fullCityGeoJSONTemp.features.length; i++) {
if (i == featureRow) {
// //console.log(fullCityGeoJSONTemp.features[i].properties);
return fullCityGeoJSONTemp.features[i].properties;
}
}
}
function initStyleCityMapFeatures(feature) {
// let getRandom = getRandomFeatureColor(fillcolorCity(iranCityCount));
let getRandom = getRandomFeatureColor(fillcolorCity(iranCityCount));
let makeStyle = {
fillColor: getRandom.color,
weight: 2,
opacity: 1,
color: "white",
fillOpacity: 0.5,
};
if (iranCityCount == fullCityGeoJSONTemp.features.length) {
iranCityCount = 0;
}
iranCityCount++;
return makeStyle;
}
function removeFeaturesFromMap() {
if (iranMapGeo) {
//console.log("gambler trump",iranMapGeo);
map4.removeLayer(iranMapGeo);
}
}
function removeFeaturesCity() {
if (fullCityGeoJSONTemp.features) {
map4.removeLayer(iranCityMapGeo);
}
}
setTimeout(() => {
iranMapGeo = L.geoJson(iranGeoJSON, {
style: initStyleMapFeatures,
onEachFeature: onEachFeature,
});
iranMapGeo.addTo(map4);
selectedProvinceId = $("#select-province").val()
zoomMapToFeature(feaLayer[list_province[selectedProvinceId - 1].abrar_feature])
}, 200);
}, 300);
}
function showSecondMapModal() {
$("#mapModalCenter2 .modal-body").empty();
$("#mapModalCenter2 .modal-body").append(`<div class="map-box">
<div id="map3" class="map3"></div>
<div hidden id="layer-spinner" class="spinner"></div>
</div>`)
$('#mapModalCenter2').modal('show')
setTimeout(() => {
var map3 = L.map("map3", {
maxBounds: bounds,
minZoom: MAP_MIN_ZOOM,
//maxZoom: MAP_MAX_ZOOM,
zoomControl: false,
}).setView([32.4279, 53.6880], 4.2);
L.tileLayer(MAP_ENDPOINT + "/141map/{z}/{x}/{y}.png", {}).addTo(map3);
}, 300);
}
$(".mini").on("click", function () {
//console.log("saaarbaz");
$(".headTitle").removeClass("selectedField")
$(this).find(".headTitle").addClass("selectedField")
field = $(this).find(".headTitle").attr("id")
})
function mainProjectRahdari() {
indexCol = 1;
callBi("i", indexCol)
$(".subText1").text("پروژه های راهداری")
$(".boxOneTypical").css("display", "block");
$(".boxOneJari").css("display", "none");
$(".typical234").css("display", "block");
$(".typical234 .card-body").css("display", "block");
$(".jari234").css("display", "none");
bar.animate(rahdariPercent);
$("#box1Title").empty();
$("#box1Title").text("میانگین پیشرفت فیزیکی کل پروژه های راهداری");
$("#select-month").prop("disabled", true);
$("#dateFrom").prop("disabled", true);
$("#dateTo").prop("disabled", true);
}
$("#project").on("click", function () {
mainProjectRahdari();
});
$("#daily").on("click", function () {
indexCol = 2;
callBi("i", indexCol)
//console.log("hey daily");
$(".subText1").text("فعالیت های راهداری")
var jariChart = document.getElementById("myChartJari").getContext("2d");
var myChartJari = new Chart(jariChart, {
type: "doughnut",
data: {
datasets: [
{
data: [
1944,
1392,
788,
1141
],
backgroundColor: [
chartColors[0],
chartColors[1],
chartColors[2],
chartColors[3],
// chartColors[4],
],
},
],
labels: [
"روستایی",
"فرعی",
"اصلی",
"شریانی",
],
},
options: {
onClick: (e) => {
//console.log("hello seven");
var sevenPoint = myChartSeventh.getElementAtEvent(e);
if (sevenPoint[0]) {
var label = myChartSeventh.data.labels[sevenPoint[0]._index];
var value = myChartSeventh.data.datasets[0].data[sevenPoint[0]._index];
//console.log("roye mood ane 7");
//console.log(label);
//console.log(value);
}
},
// scales: {
// yAxes: [{
// ticks: {
// suggestedMin: 0,
// suggestedMax: 1017
// }
// }]
// },
plugins: {
datalabels: {
anchor: "center",
align: "center",
offset: 10,
color: "#fffff",
},
},
responsive: true,
legend: {
display: false,
position: "left",
},
title: {
display: false,
text: "تفکیک پروژه های راه روستایی",
position: "bottom",
},
tooltips: {
enabled: true,
},
},
});
$(".jari234 .spanTitle").text("نوع فعالیت جاری راهداری")
$(".boxOneTypical").css("display", "none");
// $(".boxOneJari").css("display", "block");
$(".typical234").css("display", "none");
$(".jari234").css("display", "block");
$(".jari234 .card-body").css("display", "block");
$(".boxOneJari").css("display", "block");
$("#select-city").prop("disabled", false);
$("#select-year").prop("disabled", false);
$("#select-month").prop("disabled", false);
$("#dateFrom").prop("disabled", false);
$("#dateTo").prop("disabled", false);
})
$("#misson").on("click", function () {
indexCol = 3;
callBi("i", indexCol)
$(".subText1").text("ماموریت ها و گشت راهداری")
$(".jari234 .card-body").css("display", "none");
$(".typical234 .card-body").css("display", "none");
$(".boxOneTypical").css("display", "none");
$(".boxOneJari").css("display", "none");
//console.log("hey misson");
$("#select-city").prop("disabled", false);
$("#select-year").prop("disabled", false);
$("#select-month").prop("disabled", false);
$("#dateFrom").prop("disabled", false);
$("#dateTo").prop("disabled", false);
})
$("#handle").on("click", function () {
indexCol = 4;
callBi("i", indexCol)
$(".subText1").text("شکایات مردمی رسیدگی شده")
$(".jari234 .spanTitle").text("شکایات")
$(".boxOneTypical").css("display", "block");
$(".boxOneJari").css("display", "none");
$("#box1Title").text("درصد شکایات رسیدگی شده");
$(".jari234").css("display", "block");
$(".jari234 .card-body").css("display", "block");
$(".typical234 .card-body").css("display", "block");
$(".typical234").css("display", "none");
$("#select-city").prop("disabled", false);
$("#select-year").prop("disabled", false);
$("#select-month").prop("disabled", false);
$("#dateFrom").prop("disabled", false);
$("#dateTo").prop("disabled", false);
})
$("#danger95").on("click", function () {
indexCol = 5;
callBi("i", indexCol)
$(".subText1").text("نقاط حادثه خیز رفع شده مصوب 1395")
$(".jari234").css("display", "none");
//console.log("hey danger95");
$(".boxOneTypical").css("display", "block");
$(".boxOneJari").css("display", "none");
bar.animate(0.34);
$("#box1Title").empty();
$("#box1Title").text("درصد نقاط رفع شده به کل نقاط");
$(".typical234").css("display", "none");
$(".card23").css("display", "block");
$("#select-year").prop("disabled", true);
$("#select-month").prop("disabled", true);
$("#dateFrom").prop("disabled", true);
$("#dateTo").prop("disabled", true);
})
$("#danger99").on("click", function () {
callBi("i", indexCol)
$(".subText1").text("نقاط حادثه خیز شناسایی شده 1399")
$(".boxOneTypical").css("display", "none");
$(".boxOneJari").css("display", "none");
$(".card23").css("display", "none");
$(".typical234 .card-body").css("display", "none");
//console.log("hey danger99");
$("#select-year").prop("disabled", true);
$("#select-month").prop("disabled", true);
$("#dateFrom").prop("disabled", true);
$("#dateTo").prop("disabled", true);
})
$("#block").on("click", function () {
indexCol = 6;
callBi("i", indexCol)
$(".subText1").text("محورهای مسدودی آسیب دیده ناشی از مخاطرات جوی")
console.log("hey block");
$(".jari234 .spanTitle").text("محور های مسدودی")
$(".boxOneTypical").css("display", "none");
$(".boxOneJari").css("display", "none");
$(".counterBlock").css("display", "flex");
bar.animate(0.95);
$("#box1Title").empty();
$("#box1Title").text("محورهای مسدودی و آسیب دیده");
$(".typical234").css("display", "none");
$(".jari234").css("display", "block");
$(".jari234 .card-body").css("display", "block");
$("#select-year").prop("disabled", false);
$("#select-month").prop("disabled", false);
$("#dateFrom").prop("disabled", false);
$("#dateTo").prop("disabled", false);
})
//daily
//misson
// handle
//danger95
// danger99
// block
//pahne bandi az injaaaaaaa
function addCityFeaturesToMap() {
console.log("fullCityGeoJSONTemp", fullCityGeoJSONTemp)
keepMapFeatureColor = null;
if (fullCityGeoJSONTemp) {
iranCityMapGeo = L.geoJson(fullCityGeoJSONTemp, {
style: initStyleCityMapFeatures,
onEachFeature: onEachCityFeature,
});
iranCityMapGeo.addTo(map);
}
}
function getForArrayFeatureColor(arrayNum) {
//console.log("sortable" ,sortable);
//console.log("arrayNum" ,arrayNum);
//console.log("charakDovom" , charakDovom);
//console.log("charakAval" , charakAval);
// if(arrayNum = 300){
// //console.log("mask" ,arrayNum >= charakDovom );
// }
if (keepMapFeatureColor) {
return { num: -1, color: keepMapFeatureColor };
} else {
// console.log("fariba" , arrayNum , );
// console.log("ghasam" , arrayNum >= charakDovom , );
return arrayNum >= charakDovom
? { num: arrayNum, color: "#66cc66" }
: arrayNum > charakAval
? { num: arrayNum, color: "#ffeda0" }
: { num: arrayNum, color: "#ff704d" };
}
}
function fillcolorme(featureRow) {
// console.log("witel", pahneArray);
for (let i = 0; i < pahneArray.length; i++) {
if (i == featureRow) {
// console.log("mehr", i);
// console.log("jan", pahneArray[i]);
return pahneArray[i];
}
}
}
function initStyleMapFeatures() {
let getRandom = null;
getRandom = getForArrayFeatureColor(fillcolorme(iranArrayCount));
let makeStyle = {
fillColor: getRandom.color,
weight: 2,
opacity: 1,
color: "white",
fillOpacity: 0.7,
};
if (getRandom.num != -1) {
if (iranArrayCount == 35) {
iranArrayCount = 0;
}
iranArrayCount++;
}
return makeStyle;
}
function highlightMapFeature(e) {
let targetAtt = e.target.feature.properties;
let featureLayer = null;
if (e.target) {
featureLayer = e.target;
} else {
featureLayer = e;
}
keepMapFeatureColor = featureLayer.options.fillColor;
featureLayer.setStyle({
weight: 4,
color: "#666",
fillOpacity: 0.85,
});
if (!L.Browser.ie && !L.Browser.opera && !L.Browser.edge) {
featureLayer.bringToFront();
}
}
function resetMapFeatureHighlight(e) {
let targetAtt = e.target.feature.properties;
let featureLayer = null;
if (e.target) {
featureLayer = e.target;
} else {
featureLayer = e;
}
iranMapGeo.resetStyle(featureLayer);
keepMapFeatureColor = null;
}
function zoomMapToFeature(e) {
console.log("e", e)
$(".subText2").empty()
//console.log("mashala");
removeFeaturesCity();
if (e.type) {
$("#select-province").val(e.target.feature.properties.province_id)
//console.log("bokhormosh", e.target);
}
if (e.target) {
callBi("p", indexCol, e.target.feature.properties.province_id,)
$(".subText2").text(e.target.feature.properties.province_name)
// console.log("bokhor", e.target);
// $.ajax({
// url: "https://rms.rmto.ir/api/bi?pp=" +
// e.target.feature.properties.province_id,
// type: "GET",
// cache: false,
// contentType: false,
// processData: false,
// success: function (result) {
// //console.log("avalish", result);
// citiesArray = result.rahdari.p_ostani;
// },
// error: function (error) { },
// });
} else {
$(".subText2").text(e.feature.properties.province_name)
callBi("p", indexCol, e.feature.properties.province_id,)
// $.ajax({
// url: "https://rms.rmto.ir/api/bi?pp=" +
// e.feature.properties.province_id,
// type: "GET",
// cache: false,
// contentType: false,
// processData: false,
// success: function (result) {
// //console.log("dovomish", result);
// citiesArray = result.rahdari.p_ostani;
// },
// error: function (error) { },
// });
}
let featureLayer = null;
let featuresLayerCity = [];
if (e.target) {
featureLayer = e.target;
} else {
featureLayer = e;
}
// //console.log("this is on ke mikhahi ",featureLayer);
map.flyToBounds(featureLayer.getBounds());
// showLoaderScreen();
removeFeaturesFromMap();
// removeCityFeaturesFromMap();
fullCityGeoJSONTemp.type = "FeatureCollection";
console.log("fullCityGeoJSONTemp", fullCityGeoJSONTemp)
$.each(fullCityGeoJSON.features, function (key, value) {
if (
value &&
featureLayer.feature.properties.province_id ===
value.properties.province_id
) {
featuresLayerCity.push(value);
} else {
//
}
});
console.log("fullCityGeoJSONTempbefor", fullCityGeoJSONTemp)
setTimeout(function () {
console.log("fullCityGeoJSONTempafter", fullCityGeoJSONTemp)
//todo pooria
fullCityGeoJSONTemp.features = featuresLayerCity;
for (let i = 0; i < fullCityGeoJSONTemp.features.length; i++) {
for (let j = 0; j < citiesArray.length; j++) {
if (
fullCityGeoJSONTemp.features[i].properties.city_id ==
citiesArray[j].city_id
) {
fullCityGeoJSONTemp.features[i].properties["abrar_process"] = indexCol == 1 ?
citiesArray[j].cnt : citiesArray[j].total;
}
}
}
addCityFeaturesToMap();
}, 1000);
setTimeout(function () {
// hideLoaderScreen();
}, 1500);
flagProvince = 1;
iranCityCount = 0;
}
$(".backStack").on("click", function () {
removeFeaturesCity();
});
function onEachFeature(feature, featureLayer) {
feaLayer.push(featureLayer);
featureLayer.on({
mouseover: highlightMapFeature,
mouseout: resetMapFeatureHighlight,
click: zoomMapToFeature,
});
}
function onEachCityFeature(feature, featureLayer) {
featureLayer.on({
mouseover: highlightMapFeature,
mouseout: resetMapFeatureHighlight,
//click: zoomMapToFeature
});
}
function getRandomFeatureColor(arrayNum) {
if (keepMapFeatureColor) {
return { num: -1, color: keepMapFeatureColor };
} else {
return arrayNum.abrar_process >= charakDovom
? { num: arrayNum, color: "#66cc66" }
: arrayNum.abrar_process > charakAval
? { num: arrayNum, color: "#ffeda0" }
: { num: arrayNum, color: "#ff704d" };
}
}
function fillcolorCity(featureRow) {
// //console.log(featureRow);
for (let i = 0; i < fullCityGeoJSONTemp.features.length; i++) {
if (i == featureRow) {
// //console.log(fullCityGeoJSONTemp.features[i].properties);
return fullCityGeoJSONTemp.features[i].properties;
}
}
}
function initStyleCityMapFeatures(feature) {
// let getRandom = getRandomFeatureColor(fillcolorCity(iranCityCount));
let getRandom = getRandomFeatureColor(fillcolorCity(iranCityCount));
let makeStyle = {
fillColor: getRandom.color,
weight: 2,
opacity: 1,
color: "white",
fillOpacity: 0.5,
};
if (iranCityCount == fullCityGeoJSONTemp.features.length) {
iranCityCount = 0;
}
iranCityCount++;
return makeStyle;
}
function removeFeaturesFromMap() {
if (iranMapGeo) {
map.removeLayer(iranMapGeo);
}
}
function removeFeaturesCity() {
if (fullCityGeoJSONTemp.features) {
map.removeLayer(iranCityMapGeo);
}
}
//pahne bandi end
function callBi(type, index, prov) {
removeFeaturesCity();
console.log("ajxurl" + ajaxUrl);
var params = ajaxUrl.searchParams;
// var i = url.searchParams.get("i");
console.log("this index", index);
console.log("this type", type);
if (type == "i") {
params.set("i", index);
console.log("i kkk");
} else if (type == "p") {
params.set("p", prov);
console.log("p kkk");
} else if (type == "c") {
params.set("c", index);
} else if (type == "y") {
params.set("c", index);
} else if (type == "dt") {
params.set("df", index);
} else if (type == "df") {
params.set("dt", index);
}
console.log("pachi", ajaxUrl);
console.log("now search", ajaxUrl.search);
// console.log("this sas" , window.location.search.substr(1));
$.ajax({
url: ajaxUrl.href,
// url: "https://rms.rmto.ir/public/bama-homepage",
type: "GET",
cache: false,
success: function (result) {
console.log("BAZI", result);
if (ajaxUrl.search.indexOf("i=2") > -1) {
// myChartJariSecond
var listItems = result.items.item;
var listitemVal = [];
var listitemName = [];
var listitemColor = [];
for (var index in listItems) {
listitemVal.push(listItems[index]["total"]);
listitemName.push("item_fa")
listitemColor.push("#2aa9db")
}
console.log("miamp", listItems);
console.log("chera1", myChartSixth);
console.log("chera1", myChartJariSecond);
changeChartData(myChartJariSecond, listitemVal, listitemColor, listitemName)
console.log("karish", listItems);
} else if (ajaxUrl.search.indexOf("i=4") > -1) {
bar.animate(parseInt(result.observds.avg[0].ag) / 100);
var listItems = result.observds.chart_2_3;
var listitemVal = [];
var listitemName = [];
var listitemColor = [];
for (var index in listItems) {
listitemVal.push(listItems[index]["cnt"]);
listitemName.push(listItems[index]["FeatureTypeTitle"])
listitemColor.push("#2aa9db")
}
changeChartData(myChartJariSecond, listitemVal, listitemColor, listitemName)
} else if (ajaxUrl.search.indexOf("i=5") > -1) {
bar.animate(parseInt(result.acc_points.avg) / 100);
var listItems = result.acc_points.chart2_3;
var listitemVal = [];
var listitemName = [];
var listitemColor = [];
for (var index in listItems) {
listitemVal.push(listItems[index]["cnt"]);
listitemName.push(listItems[index]["geometric_desc"])
listitemColor.push("#2aa9db")
}
console.log("zero", listItems);
console.log("one", listitemVal);
console.log("two", listitemName);
console.log("three", listitemColor);
console.log("four", myChart23);
changeChartData(myChart23, listitemVal, listitemColor, listitemName)
} else if (ajaxUrl.search.indexOf("i=6") > -1) {
bar.animate(parseInt(result.rahdari.avg[0]["ag"]) / 100);
} else if (ajaxUrl.search.indexOf("i=7") > -1) {
var countTo = result.charts.staticks;
console.log("joji", parseInt(result.charts.staticks));
console.log("joji", parseInt(result.charts.staticks) / 221353);
bar.animate(parseInt(result.charts.staticks) / 221353);
$({ countNum: $("#counterTak").text() }).animate({
countNum: countTo
},
{
duration: 3000,
easing: 'linear',
step: function () {
$("#counterTak").text(Math.floor(this.countNum));
},
complete: function () {
$("#counterTak").text(this.countNum);
}
});
var listItems = result.charts.chart_2_3_4;
var listitemVal = [];
var listitemName = [];
var listitemColor = [];
for (var index in listItems) {
listitemVal.push(listItems[index]["cnt"]);
listitemName.push(listItems[index]["blockage_cause_fa"])
listitemColor.push("#2aa9db")
}
console.log("zero", listItems);
console.log("one", listitemVal);
console.log("two", listitemName);
console.log("three", listitemColor);
console.log("four", myChart23);
// changeChartData(myChart23, listitemVal, listitemColor, listitemName)
changeChartData(myChartJariSecond, listitemVal, listitemColor, listitemName, 50)
}
if (ajaxUrl.search.indexOf("i=1") > -1 || ajaxUrl.search.indexOf("i=6") > -1) {
console.log("bikhodi");
ShowBi(result);
}
else
if (ajaxUrl.search.indexOf("p=") > -1) {
citiesArray = result.pahne;
console.log("hi bitxh", citiesArray);
ShowBiS(result);
}
else if (ajaxUrl.search.indexOf("i=7") <= -1) {
citiesArray = result.pahne;
ShowBiO(result);
}
resu = result;
},
error: function (error) {
//console.log(error);
},
});
}
// function addData(chart, label, data) {
// chart.data.labels.push(label);
// chart.data.datasets.forEach((dataset) => {
// dataset.data.push(data);
// });
// chart.update();
// }
// function removeData(chart) {
// console.log("kisi", chart);
// // chart.data.labels.pop();
// // chart.data.datasets.forEach((dataset) => {
// // dataset.data.pop();
// // });
// chart.data.datasets[0].data=[
// 1,2,3,4
// ]
// chart.update();
// }
function changeChartData(chart, newData, backgroundColor, labels, max) {
console.log("BARJAM", newData);
console.log("bargam", chart.data);
chart.data.datasets[0].data = newData
chart.data.datasets[0].backgroundColor = backgroundColor
chart.data.labels = labels
chart.options.scales.yAxes[0].ticks.suggestedMax = max;
chart.update();
}
function refreshSomething() {
$("#select-province").val(0);
// let hold_idSelect = $("#select-province").val();
if ($("#select-province").val() == 0) {
// $("#select-city").empty();
$("#select-city option").remove();
// $("#select-city option").html("انتخاب شهرستان");
var mySecondDiv = $("<option></option>");
$("#select-city").append(mySecondDiv);
$("#select-city option").html("انتخاب شهرستان");
$("#select-city option").val(0);
}
$("#select-year").val(0);
$("#select-month").val(0);
$('#dateTo').val(forRefresh);
$('#dateFrom').val(forRefresh);
// $("#dateTo").datepicker( "placeholder", "gotoCurrent", true );
}
$("#refresh-buttom").on("click", function () {
refreshSomething();
});
$('#select-province').on('change', function () {
if ($("#select-province").val() != 0) {
$(".subTextBet1").css("display", "unset");
}
$(".subTextBet2").css("display", "none");
$(".subText3").empty();
});
$('#select-city').on('change', function () {
if ($("#select-city").val() != 0) {
$(".subTextBet2").css("display", "unset");
$(".subText3").text($("#select-city option:selected").text() + ")");
}
});
//for download button
// $(".leaflet-download-jpg").on("click", function() {
// });
$(".go-home").on("click", function () {
// refreshSomething();
// mainProjectRahdari();
// if($(".headTitle").hasClass("selectedField") == true) {
// $(".headTitle").removeClass("selectedField");
// }
// $("#project").addClass("selectedField");
// $(".subTextBet1").css("display", "none");
// $(".subText2").css("display", "none");
// $(".subTextBet2").css("display", "none");
// $(".subText3").css("display", "none");
location.reload();
});