'; $('.forcast-aqi-no' + i).html(html); } var result = respJson['Data'][0]; var result_day = result['day']; var result_val = result['value']; //console.log(result); var today = new Date(result_day); //console.log(today); var day = today.getDay(); var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; var dayname = days[day]; //console.log(dayname); /* var html = ''; html +='
'; const shapes = ['square']; const colors = [aqicolor]; const space = 0.005; const lat = obj['lat']; const lng = obj['lon']; const lats = shapes.slice().map((shape, i) => lat); const lngs = colors.slice().map((x, i) => lng); const rows = lats.map((y) => lngs.map(x => [y, x])); // Define test cases const tests = [{ icon: `fa-number aqi_toggle-${i}`, number: aqivaluemini, svg: true, }]; rows.forEach((row, shapeIdx) => { row.forEach((col, colorIdx) => { L.marker(col, { locdata: obj, icon: L.ExtraMarkers.icon( Object.assign( {}, tests[(shapeIdx * row.length + colorIdx) % tests.length], { shape: shapes[shapeIdx], markerColor: colors[colorIdx] }, ) ) }).bindPopup(infowindow, { direction: 'top', permanent: true, opacity: 1 }).addTo(group); }) }); } } map.addLayer(group); } function GetImageTextColorjs(aqi, time) { var aqicolor; var aqimage; var aqitext; var bgaqimage; var cartoonimg; var aqibgcolor; var obj; if (time > "00:00:00" && time <= "05:00:00") {//night if (aqi >= 0 && aqi <= 50) { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-n1.png"; cartoonimg = "https://www.aqi.in/assets/images/good-aqi-boy.png"; aqibgcolor = "#c0f2e3"; } else if (aqi > 50 && aqi <= 100) { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-n2.png"; cartoonimg = "https://www.aqi.in/assets/images/moderate-aqi-boy.png"; aqibgcolor = "#feff7f"; } else if (aqi > 100 && aqi <= 150) { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-n3.png"; cartoonimg = "https://www.aqi.in/assets/images/poor-aqi-boy.png"; aqibgcolor = "#fde9d7"; } else if (aqi > 150 && aqi <= 200) { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-n4.png"; cartoonimg = "https://www.aqi.in/assets/images/unhealthy-aqi-boy-image.png"; aqibgcolor = "#fdc9e6"; } else if (aqi > 200 && aqi <= 300) { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-n5.png"; cartoonimg = "https://www.aqi.in/assets/images/severe-aqi-boy.png"; aqibgcolor = "#f3ddf5"; } else { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-n6.png"; cartoonimg = "https://www.aqi.in/assets/images/hazardous-aqi-boy.png"; aqibgcolor = "#ffe1e6"; } } if (time > "05:00:00" && time <= "10:00:00") {//morning if (aqi >= 0 && aqi <= 50) { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-m1.png"; cartoonimg = "https://www.aqi.in/assets/images/good-aqi-boy.png"; aqibgcolor = "#bef2a0"; } else if (aqi > 50 && aqi <= 100) { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-m2.png"; cartoonimg = "https://www.aqi.in/assets/images/moderate-aqi-boy.png"; aqibgcolor = "#f5efb9"; } else if (aqi > 100 && aqi <= 150) { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-m3.png"; cartoonimg = "https://www.aqi.in/assets/images/poor-aqi-boy.png"; aqibgcolor = "#ecc9b8"; } else if (aqi > 150 && aqi <= 200) { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-m4.png"; cartoonimg = "https://www.aqi.in/assets/images/unhealthy-aqi-boy-image.png"; aqibgcolor = "#fccefa"; } else if (aqi > 200 && aqi <= 300) { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-m5.png"; cartoonimg = "https://www.aqi.in/assets/images/severe-aqi-boy.png"; aqibgcolor = "#ecb9f7"; } else { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-m6.png"; cartoonimg = "https://www.aqi.in/assets/images/hazardous-aqi-boy.png"; aqibgcolor = "#f5a3a7"; } } if (time > "10:00:00" && time <= "16:00:00") {//afternoon if (aqi >= 0 && aqi <= 50) { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-a1.png"; cartoonimg = "https://www.aqi.in/assets/images/good-aqi-boy.png"; aqibgcolor = "#c0f2e3"; } else if (aqi > 50 && aqi <= 100) { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-a2.png"; cartoonimg = "https://www.aqi.in/assets/images/moderate-aqi-boy.png"; aqibgcolor = "#feff7f"; } else if (aqi > 100 && aqi <= 150) { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-a3.png"; cartoonimg = "https://www.aqi.in/assets/images/poor-aqi-boy.png"; aqibgcolor = "#fde9d7"; } else if (aqi > 150 && aqi <= 200) { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-a4.png"; cartoonimg = "https://www.aqi.in/assets/images/unhealthy-aqi-boy-image.png"; aqibgcolor = "#fdc9e6"; } else if (aqi > 200 && aqi <= 300) { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-a5.png"; cartoonimg = "https://www.aqi.in/assets/images/severe-aqi-boy.png"; aqibgcolor = "#f3ddf5"; } else { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-a6.png"; cartoonimg = "https://www.aqi.in/assets/images/hazardous-aqi-boy.png"; aqibgcolor = "#ffe1e6"; } } if (time > "16:00:00" && time <= "20:00:00") {//evening if (aqi >= 0 && aqi <= 50) { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-e1.png"; cartoonimg = "https://www.aqi.in/assets/images/good-aqi-boy.png"; aqibgcolor = "#c0f2e3"; } else if (aqi > 50 && aqi <= 100) { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-e2.png"; cartoonimg = "https://www.aqi.in/assets/images/moderate-aqi-boy.png"; aqibgcolor = "#feff7f"; } else if (aqi > 100 && aqi <= 150) { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-e3.png"; cartoonimg = "https://www.aqi.in/assets/images/poor-aqi-boy.png"; aqibgcolor = "#fde9d7"; } else if (aqi > 150 && aqi <= 200) { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-e4.png"; cartoonimg = "https://www.aqi.in/assets/images/unhealthy-aqi-boy-image.png"; aqibgcolor = "#fccefa"; } else if (aqi > 200 && aqi <= 300) { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-e5.png"; cartoonimg = "https://www.aqi.in/assets/images/severe-aqi-boy.png"; aqibgcolor = "#f3ddf5"; } else { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-e6.png"; cartoonimg = "https://www.aqi.in/assets/images/hazardous-aqi-boy.png"; aqibgcolor = "#ffe1e6"; } } if (time > "20:00:00" && time <= "23:59:00") {//night if (aqi >= 0 && aqi <= 50) { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-n1.png"; cartoonimg = "https://www.aqi.in/assets/images/good-aqi-boy.png"; aqibgcolor = "#c0f2e3"; } else if (aqi > 50 && aqi <= 100) { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-n2.png"; cartoonimg = "https://www.aqi.in/assets/images/moderate-aqi-boy.png"; aqibgcolor = "#feff7f"; } else if (aqi > 100 && aqi <= 150) { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-n3.png"; cartoonimg = "https://www.aqi.in/assets/images/poor-aqi-boy.png"; aqibgcolor = "#fde9d7"; } else if (aqi > 150 && aqi <= 200) { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-n4.png"; cartoonimg = "https://www.aqi.in/assets/images/unhealthy-aqi-boy-image.png"; aqibgcolor = "#fdc9e6"; } else if (aqi > 200 && aqi <= 300) { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-n5.png"; cartoonimg = "https://www.aqi.in/assets/images/severe-aqi-boy.png"; aqibgcolor = "#f3ddf5"; } else { bgaqimage = "https://www.aqi.in/assets/images/bg-mobile-img-n6.png"; cartoonimg = "https://www.aqi.in/assets/images/hazardous-aqi-boy.png"; aqibgcolor = "#ffe1e6"; } } obj = { "bgaqimage": bgaqimage, "cartoonimg": cartoonimg, "aqibgcolor": aqibgcolor }; return obj; } $(".temp_c").click(function () { var temp_c = $(".card-cloudy-text-temp_c").text(); temp_c = Math.round(temp_c); $(".card-cloudy-text-temp").html(temp_c); /*if($(".temp_f").css("color","#46C4FF"); === true){ $(".temp_f").css("color","#333333"); }*/ $(".temp_f").css("color", "#333333"); $(".temp_c").css("color", "#46C4FF"); }); $(".temp_f").click(function () { var temp_f = $(".card-cloudy-text-temp_f").text(); temp_f = Math.round(temp_f); $(".card-cloudy-text-temp").html(temp_f); $(".temp_c").css("color", "#333333"); $(".temp_f").css("color", "#46C4FF"); }); // console.log(pollitantcities); var weither_html = ''; var polluted_html = ''; var polluted_html1 = ''; var polluted_html2 = ''; var comp_html = ''; var locationName = "Keene"; var aqi_per = "1.7017017017017"; var aqi = "17"; var aqicoldivor = "#34a12b"; var location_city_textdata = "#34a12b"; var aqi_px = "0"; var country_Aqi1 = "United States"; var coun_aqi = "30"; var location_city_per = ""; var location_city_value_px = ""; var location_city_name_text = "Keene"; var country_aqi_per = "3.003003003003"; var coun_aqi_textdata = "#34a12b"; var coun_aqi_px = "1"; var location_city_name_text = "Keene"; var location_city_value = ""; var countryNameAqi = ""; /*setTimeout(function(){ Comparitive_data(); },1000);*/ const part10 = ""; const part25 = "4"; console.log("PM VALUES", part10, part25) const intpm10 = parseInt(part10); const intpm25 = parseInt(part25); console.log("pm", intpm10, intpm25) if (intpm10 > intpm25) { $(".mobile_card_bg1_pm").text(intpm10) $(".mobile_card_bg1_pm_text").text("pm10") } else if (intpm10 < intpm25) { $(".mobile_card_bg1_pm").text(intpm25) $(".mobile_card_bg1_pm_text").text("pm2.5") } else if (!intpm10) { $(".mobile_card_bg1_pm").text(intpm25) $(".mobile_card_bg1_pm_text").text("pm2.5") } else if (!intpm25) { $(".mobile_card_bg1_pm").text(intpm10) $(".mobile_card_bg1_pm_text").text("pm10") } else { $(".mobile_card_bg1_pm").text(intpm10) $(".mobile_card_bg1_pm_text").text("pm10") } function Comparitive_data() { comp_html += '
Comparitive Exposure with ' + locationName + '
>
' + aqi_px + 'x
'; if (country_Aqi1 == "india" || country_Aqi1 == "India") { comp_html += '
' + location_city_value_px + 'x
'; } comp_html += '
' + coun_aqi_px + 'x
' + locationName + '
' + aqi + '
'; if (country_Aqi1 == "india" || country_Aqi1 == "India") { comp_html += '
' + location_city_name_text + '
' + location_city_value + '
'; } comp_html += '
' + country_Aqi1 + '
' + coun_aqi + '
'; $('.comp-card-live1').append(comp_html); } var aqiType = getCookie("aqiType") === "AQI-IN" ? "AQI-IN" : "AQI-US"; polluted_html += '
Most Polluted Cities in United States
Real-time worst city rankings
Rank
City
' + aqiType + '
'; polluted_html += '
'; var pollitantcities_count = pollitantcities['Locations']; pollitantcities_count = pollitantcities_count.length + 1; for (var i = 1; i < pollitantcities_count; i++) { polluted_html += '
' + i + '
'; } polluted_html += '
'; // console.log(pollitantcities['Locations']); for (var i in pollitantcities['Locations']) { /* if(pollitantcities['Locations'][i]['countryName'] == "India" || pollitantcities['Locations'][i]['countryName'] == "india"){ */ var pollitant_city = pollitantcities['Locations'][i]['cityName']; pollitant_city = pollitant_city.toLowerCase(); pollitant_city = pollitant_city.replace(/\s/g, '-'); var pollitant_state = pollitantcities['Locations'][i]['stateName']; pollitant_state = pollitant_state.toLowerCase(); pollitant_state = pollitant_state.replace(/\s/g, '-'); var pollitant_con = pollitantcities['Locations'][i]['countryName']; pollitant_con = pollitant_con.toLowerCase(); pollitant_con = pollitant_con.replace(/\s/g, '-'); pollitant_city = pollitant_city.toLowerCase().replace(/\b[a-z]/g, function (letter) { return letter.toUpperCase(); }); pollitant_con = pollitant_con.toLowerCase().replace(/\b[a-z]/g, function (letter) { return letter.toUpperCase(); }); // if(pollitantcities['Locations'][i]['countryName'] == "India" || pollitantcities['Locations'][i]['countryName'] == "india"){ var areaurl = 'https://www.aqi.in/us/dashboard/' + pollitant_con.toLowerCase() + '/' + pollitant_state + '/' + pollitant_city.toLowerCase(); // }else{ // var areaurl = baseurl+'dashboard/'+pollitant_con.toLowerCase()+'/'+pollitant_city.toLowerCase(); // } polluted_html += '
' + pollitant_city.replace(/-/g, ' ') + ', ' + pollitant_con + '
'; /* }*/ } polluted_html += '
'; for (var i in pollitantcities['Locations']) { var aqiType = getCookie("aqiType") === "AQI-IN" ? "AQI-IN" : "AQI-US"; if (getCookie("aqiType") === "AQI-IN") { var pollitant_aqi = pollitantcities['Locations'][i]['AQI-IN']; var pollitant_aqi_name = "AQI-IN"; } else { var pollitant_aqi = pollitantcities['Locations'][i]['aqi']; var pollitant_aqi_name = "aqi"; } var pollitant_aqi_color = GetColorBySensorNameAndValue(pollitant_aqi_name, pollitant_aqi); polluted_html += `
${pollitant_aqi == undefined ? obj['aqi'] : pollitant_aqi}
`; } polluted_html += '
View Full Ranking
'; $('.most_polluted_cities').append(polluted_html); polluted_html1 += '
Least Polluted Cities in United States
Real-time best city rankings
Rank
City
' + aqiType + '
'; polluted_html1 += '
'; var least_pollutantcities_count = least_pollutantcities['Locations']; least_pollutantcities_count = least_pollutantcities_count.length + 1; for (var i = 1; i < least_pollutantcities_count; i++) { polluted_html1 += '
' + i + '
'; } polluted_html1 += '
'; for (var i in least_pollutantcities['Locations']) { var pollitant_city1 = least_pollutantcities['Locations'][i]['locationName']; pollitant_city1 = pollitant_city1.toLowerCase(); pollitant_city1 = pollitant_city1.replace(/\s/g, '-'); var pollitant_state1 = least_pollutantcities['Locations'][i]['stateName']; pollitant_state1 = pollitant_state1.toLowerCase(); pollitant_state1 = pollitant_state1.replace(/\s/g, '-'); var pollitant_con1 = least_pollutantcities['Locations'][i]['countryName']; pollitant_con1 = pollitant_con1.toLowerCase(); pollitant_con1 = pollitant_con1.replace(/\s/g, '-'); pollitant_city1 = pollitant_city1.toLowerCase().replace(/\b[a-z]/g, function (letter) { return letter.toUpperCase(); }); pollitant_con1 = pollitant_con1.toLowerCase().replace(/\b[a-z]/g, function (letter) { return letter.toUpperCase(); }); // if(least_pollutantcities['Locations'][i]['countryName'] == "India" || least_pollutantcities['Locations'][i]['countryName'] == "india"){ var areaurl1 = 'https://www.aqi.in/us/dashboard/' + pollitant_con1.toLowerCase() + '/' + pollitant_state1 + '/' + pollitant_city1.toLowerCase(); // }else{ // var areaurl1 = baseurl+'dashboard/'+pollitant_con1.toLowerCase()+'/'+pollitant_city1.toLowerCase(); // } polluted_html1 += '
' + pollitant_city1.replace(/-/g, ' ') + ', ' + pollitant_con1 + '
'; } polluted_html1 += '
'; for (var i in least_pollutantcities['Locations']) { if (getCookie("aqiType") === "AQI-IN") { var pollitant_aqi = least_pollutantcities['Locations'][i]['AQI-IN']; var pollitant_aqi_name = "AQI-IN"; } else { var pollitant_aqi = least_pollutantcities['Locations'][i]['aqi']; var pollitant_aqi_name = "aqi"; } var pollitant_aqi_color = GetColorBySensorNameAndValue(pollitant_aqi_name, pollitant_aqi); polluted_html1 += `
${pollitant_aqi == undefined ? obj['aqi'] : pollitant_aqi}
`; } polluted_html1 += '
View Full Ranking
'; $('.least_polluted_cities').append(polluted_html1); $("#owl-demo1").owlCarousel({ autoPlay: 3000, //Set AutoPlay to 3 seconds items: 1, itemsDesktop: [1199, 1], itemsDesktopSmall: [979, 3] }); ChartData1(); function ChartData1() { var coun_name = "United States"; var coun_city_name = ""; var coun_city_loc_name = "7448"; var coun_city_loc_text = "Keene"; var sensorparam = "aqi"; coun_city_loc_text = coun_city_loc_text.substring(0, 15); if (myChart2) { myChart2.destroy(); } var comparealldata = []; var optionname = []; var chartperiod = 1; var timeformat; var unit; var url; timeformat = "hA"; unit = "hour"; url = "https://api.aqi.in/api/v1/getLocationHistory24Hour"; /* console.log("coun_city_loc_name"); console.log(coun_city_loc_name);*/ var headers = { 'Authorization': authtoken, 'Content-Type': 'application/json', 'locationid': coun_city_loc_name, 'searchtype': 'locationId', 'sendevid': sensorparam }; var headerstwo = { 'Authorization': authtoken, 'Content-Type': 'application/json', 'locationid': coun_city_name, 'searchtype': 'cityId', 'sendevid': sensorparam }; var headersthree = { 'Authorization': authtoken, 'Content-Type': 'application/json', 'locationid': coun_name, 'searchtype': 'countryId', 'sendevid': sensorparam }; if (coun_name == "India" || coun_name == "india") { ChartDataT1(url, headers, headerstwo, headersthree, sensorparam, unit, timeformat, coun_name, coun_city_name, coun_city_loc_text); } else { ChartDataS2(url, headers, headersthree, sensorparam, unit, timeformat, coun_name, coun_city_loc_text); } } function ChartDataT1(url = 0, headers = 0, headerstwo = 0, headersthree = 0, sensorparam = 0, unit = 0, timeformat = 0, coun_name = 0, coun_city_name = 0, coun_city_loc_name = 0) { makeAjaxCall(url, headers, "GET", function (respJson) { //console.log(respJson); makeAjaxCall(url, headerstwo, "GET", function (respJsonTwo) { makeAjaxCall(url, headersthree, "GET", function (respJsonThree) { var location_name1 = coun_city_loc_name; var location_name2 = coun_city_name; var location_name3 = coun_name; var chartdata = respJson['Table']['Data'][0]; var colorarray = []; var chartvalueobj = chartdata['averageArray']; var chartAvgLoc = chartdata["avgValue"]; var chartdateobj = chartdata['timeArray']; var chartdataTwo = respJsonTwo['Table']['Data'][0]; var colorarrayTwo = []; var chartvalueobjTwo = chartdataTwo['averageArray']; var chartAvgCity = chartdataTwo["avgValue"]; var chartdateobjTwo = chartdataTwo['timeArray']; var chartdataThree = respJsonThree['Table']['Data'][0]; var colorarrayThree = []; var chartvalueobjThree = chartdataThree['averageArray']; var chartAvgCoun = chartdataThree["avgValue"]; var chartdateobjThree = chartdataThree['timeArray']; var bestdata = Math.min.apply(Math, chartvalueobj); // 1 var worstdata = Math.max.apply(Math, chartvalueobj); // 3 var bestindex = chartvalueobj.indexOf(bestdata); var worstindex = chartvalueobj.indexOf(worstdata); var bformatedtime = moment(chartdateobj[bestindex]).format('LT'); var bformateddate = moment(chartdateobj[bestindex]).format('LL'); var wformatedtime = moment(chartdateobj[worstindex]).format('LT'); var wformateddate = moment(chartdateobj[worstindex]).format('LL'); var start_date = moment().startOf(chartdateobj).format('YYYY-MM-DD'); var end_date = moment().endOf(chartdateobj).format('YYYY-MM-DD'); /* $('#bvalue').text(bestdata); $('#btime').text(bformatedtime); $('#bdate').text(bformateddate); $('#wvalue').text(worstdata); $('#wtime').text(wformatedtime); $('#wdate').text(wformateddate);*/ $(".Comparitive_text1_in2").text(chartAvgLoc); $(".Comparitive_text2_in2").text(chartAvgCity); $(".Comparitive_text3_in2").text(chartAvgCoun); if ($(window).width() > 640) { var ctx = document.getElementById("history_comp_graph").getContext("2d"); var grd = ctx.createLinearGradient(0.000, 350.000, 0.000, 100.000); } else { var ctx = document.getElementById("history_comp_graph_s").getContext("2d"); var grd = ctx.createLinearGradient(0.000, 350.000, 0.000, 100.000); } for (var i in chartvalueobj) { var valuecolor = GetColorBySensorNameAndValue(sensorparam, chartvalueobj[i]); colorarray.push(valuecolor); var valuecolorTwo = GetColorBySensorNameAndValue(sensorparam, chartvalueobjTwo[i]); colorarrayTwo.push(valuecolorTwo); var valuecolorThree = GetColorBySensorNameAndValue(sensorparam, chartvalueobjThree[i]); colorarrayThree.push(valuecolorThree); } var unit_type = "1"; var str = respJson['Table']['sensorName']; var res = str.toUpperCase(); //var annnot_arr=get_annotation(res,unit_type); config2 = { data: { labels: chartdateobj, datasets: [ { label: location_name1, type: 'line', data: chartvalueobj, backgroundColor: 'transparent', pointBorderColor: 'transparent', borderColor: '#39A033', pointBackgroundColor: colorarray, pointRadius: 2, borderWidth: 2, }, { label: location_name2, type: 'line', data: chartvalueobjTwo, backgroundColor: 'transparent', pointBorderColor: 'transparent', borderColor: '#D8237E', pointBackgroundColor: colorarrayTwo, pointRadius: 2, borderWidth: 2, }, { label: location_name3, type: 'line', data: chartvalueobjThree, backgroundColor: 'transparent', pointBorderColor: 'transparent', borderColor: '#289BD1', pointBackgroundColor: colorarrayThree, pointRadius: 2, borderWidth: 2, }, ] }, options: { responsive: true, maintainAspectRatio: true, animation: { easing: 'easeInOutQuad', duration: 520 }, legend: { display: true }, scales: { xAxes: [{ gridLines: { display: false }, ticks: { autoSkip: true, }, barThickness: 5, type: "time", time: { unit: unit, displayFormats: { quarter: timeformat } } }], yAxes: [{ gridLines: { display: true }, ticks: { min: 0, } }] }, legend: { display: false, labels: { // fontColor: "red", //fontSize: 18 } }, point: { backgroundColor: 'white' }, //onClick: graphClickEvent, tooltips: { mode: "index", intersect: true, enabled: true, mode: "index", position: "average", } } }; var temp = jQuery.extend(true, {}, config2); myChart2 = new Chart(ctx, temp); }); }); }); } function ChartDataS2(url = 0, headers = 0, headerstwo = 0, sensorparam = 0, unit = 0, timeformat = 0, coun_name = 0, coun_city_loc_text = 0) { makeAjaxCall(url, headers, "GET", function (respJson) { //console.log(respJson); makeAjaxCall(url, headerstwo, "GET", function (respJsonTwo) { // console.log(respJsonTwo); var chartdata = respJson['Table']['Data'][0]; var colorarray = []; var chartvalueobj = chartdata['averageArray']; var chartdateobj = chartdata['timeArray']; var chartdataTwo = respJsonTwo['Table']['Data'][0]; var colorarrayTwo = []; var chartvalueobjTwo = chartdataTwo['averageArray']; var chartdateobjTwo = chartdataTwo['timeArray']; var location_name1 = coun_city_loc_text; var location_name2 = coun_name; var bestdata = Math.min.apply(Math, chartvalueobj); // 1 var worstdata = Math.max.apply(Math, chartvalueobj); // 3 var bestindex = chartvalueobj.indexOf(bestdata); var worstindex = chartvalueobj.indexOf(worstdata); var bformatedtime = moment(chartdateobj[bestindex]).format('LT'); var bformateddate = moment(chartdateobj[bestindex]).format('LL'); var wformatedtime = moment(chartdateobj[worstindex]).format('LT'); var wformateddate = moment(chartdateobj[worstindex]).format('LL'); var start_date = moment().startOf(chartdateobj).format('YYYY-MM-DD'); var end_date = moment().endOf(chartdateobj).format('YYYY-MM-DD'); if ($(window).width() > 640) { var ctx = document.getElementById("history_comp_graph").getContext("2d"); var grd = ctx.createLinearGradient(0.000, 350.000, 0.000, 100.000); } else { var ctx = document.getElementById("history_comp_graph_s").getContext("2d"); var grd = ctx.createLinearGradient(0.000, 350.000, 0.000, 100.000); } for (var i in chartvalueobj) { var valuecolor = GetColorBySensorNameAndValue(sensorparam, chartvalueobj[i]); colorarray.push(valuecolor); var valuecolorTwo = GetColorBySensorNameAndValue(sensorparam, chartvalueobjTwo[i]); colorarrayTwo.push(valuecolorTwo); } var unit_type = "1"; var str = respJson['Table']['sensorName']; var res = str.toUpperCase(); /*var annnot_arr=get_annotation(res,unit_type);*/ config2 = { data: { labels: chartdateobj, datasets: [ { label: location_name1, type: 'line', data: chartvalueobj, backgroundColor: 'transparent', pointBorderColor: 'transparent', borderColor: '#39A033', pointBackgroundColor: colorarray, pointRadius: 1, borderWidth: 2, }, { label: location_name2, type: 'line', data: chartvalueobjTwo, backgroundColor: 'transparent', pointBorderColor: 'transparent', borderColor: '#289BD1', pointBackgroundColor: colorarrayTwo, pointRadius: 1, borderWidth: 2, }, ] }, options: { /* annotation: { annotations:annnot_arr },*/ responsive: true, maintainAspectRatio: true, animation: { easing: 'easeInOutQuad', duration: 520 }, legend: { display: true }, scales: { xAxes: [{ gridLines: { display: false }, ticks: { autoSkip: true, }, barThickness: 5, type: "time", time: { unit: unit, displayFormats: { quarter: timeformat } } }], yAxes: [{ gridLines: { display: true }, ticks: { min: 0, } }] }, legend: { display: false, labels: { //fontColor: "red", //fontSize: 18 } }, point: { backgroundColor: 'white' }, //onClick: graphClickEvent, tooltips: { mode: "index", intersect: true, enabled: true, mode: "index", position: "average", } } }; var temp = jQuery.extend(true, {}, config2); myChart2 = new Chart(ctx, temp); }); }); } const aqiIndia = "14"; const aqiUsa = "17"; console.log("Aqi ind and us", "Keene") progressRing({ "aqiIn": aqiIndia, "aqiUs": aqiUsa }); function progressRing(obj) { var location = "Keene"; location = location.charAt(0).toUpperCase() + location.slice(1); if (screen.width < 520) { if (location.length > 25) { const name = location.split(" ") const shortName = name[0] + " " + name[1] + "..."; location = shortName; } } console.log("OBJECTR", singlelocations) var pageHeading = ''; pageHeading += "
Real-time PM2.5, PM10 air pollution level
Last Updated: 31 Aug 2024, 08:05am
"; $(".card-header-h1").html(pageHeading); var total_goals = 999; var goals_completed = getCookie("aqiType") === "AQI-IN" ? obj.aqiIn : obj.aqiUs; var goal_color = getCookie("aqiType") === "AQI-IN" ? GetColorBySensorNameAndValue("AQI-IN", goals_completed) : GetColorBySensorNameAndValue("aqi", goals_completed); var country_aqi = "(AQI)"; console.log("AQIfdfdVALUE", goals_completed, location); console.log(goal_color); var bar = new ProgressBar.Circle(progress_ring_aqi, { color: goal_color, // This has to be the same size as the maximum width to // prevent clipping strokeWidth: 8, trailWidth: 7, easing: 'easeInOut', duration: 1400, text: { autoStyleContainer: false }, from: { color: goal_color, width: 9 }, to: { color: goal_color, width: 9 }, // Set default step function for all animate calls step: function (state, circle) { circle.path.setAttribute('stroke', state.color); circle.path.setAttribute('stroke-width', state.width); var value = Math.round(circle.value() * 999); if (value === 0) { circle.setText(''); } else { console.log("VALUE LOCATION", value) circle.setText(value); $(".progressbar-text").css("color", goal_color) } } }); bar.text.style.fontFamily = 'Nunito Sans, sans-serif'; bar.text.style.fontSize = '20px'; bar.text.style.color = "#f4f4f4"; bar.text.style.fontWeight = '800'; var g = "1"; bar.animate(goals_completed / total_goals); // Number from 0.0 to 1.0 }