var tmax_9 = new Array(); var tmin_9 = new Array(); var time_9 = new Array(); var date_week_9 = new Array(); var tmax_9_markPoint = new Array(); var tmin_9_markPoint = new Array(); $(function () { day10(); Foshorttime(); Titfodaily(); }); var foid_wea_val = { 0: "Clear", 1: "Cloudy", 2: "Overcast", 3: "Shower", 4: "Thundershower", 5: "Thundershower with hail", 6: "Sleet", 7: "Light rain", 8: "Moderate rain", 9: "Heavy rain", 10: "Rainstorm", 11: "Heavy rainstorm", 12: "Extraordinary rainstorm", 13: "Snow shower", 14: "Light snow", 15: "Moderate snow", 16: "Heavy snow", 17: "Blizzard", 18: "Fog", 19: "Freezing rain", 20: "Sandstorm", 21: "Light to moderate rain", 22: "Moderate to heavy rain", 23: "Heavy rain to rainstorm", 24: "Rainstorm to heavy rainstorm", 25: "Heavy rainstorm to extraordinary rainstorm", 26: "Light to moderate snow", 27: "Moderate to heavy snow", 28: "Heavy snow to blizzard", 29: "Floating dust", 30: "Sand blowing", 31: "Strong sandstorm", 53: "Haze" }; ///////////////////////////////////////////// function day10() { $.getJSON("/weather/data/10day.js?t=" + Math.random(), function (json) { if (json) { var dayNames = new Array("Sun.", "Mon.", "Tues.", "Wed.", "Thur.", "Fri.", "Sat."); var datetime = new Date(json[0]["datetime"].replace(/-/g, "/")); //转换成Data(); var datehour = datetime.getHours(); var create_date = json[0]["create_date"].substring(0, (json[0]["create_date"].length - 10)); var create_datetime = new Date(create_date.replace(/-/g, "/")); var datehour = datetime.getHours(); if (datehour >= 6 && datehour <= 11) { if ($("#date_fb").length > 0) { $("#date_fb").append(create_datetime.Format('yyyy-MM-dd hh:mm')) }; datetime.setDate(datetime.getDate()); } else { if ($("#date_fb").length > 0) { $("#date_fb").append(create_datetime.Format('yyyy-MM-dd hh:mm')) }; datetime.setDate(datetime.getDate() + 1); } var strbtit = new Array(); for (var i = 1; i <= 10; i++) { var _tmax = json[0]["tmax" + i + ""]; var _tmin = json[0]["tmin" + i + ""]; //strbtit.push("" + datetime.Format('MM/dd') + "
" + dayNames[datetime.getDay()] + "

\""
"); strbtit.push("" + datetime.Format('MM/dd') + "
" + dayNames[datetime.getDay()] + "

\""
"); time_9.push(datetime.Format('MM/dd')); tmax_9.push(_tmax); tmin_9.push(_tmin); datetime.setDate(datetime.getDate() + 1); } $("#littit_10").append(strbtit.join("")); $("#littit_10 span:last").css("background", "none"); line_10day(); } }) } function Foshorttime() { var _StationName = {"59828": ["Chancheng", 0]};//站点名称 $.getJSON("/weather/data/wc_last.js?t=" + Math.random(), function (json_wcLast) { if (json_wcLast) { var datetime = new Date(); var PeriodPath = "day"; if (datetime.getHours() >= 19 || datetime.getHours() < 7) PeriodPath = "night"; var strcontent = "FoShan"; $(".foshort_area").append(strcontent); var strcx = ""; $("#folo10d_wc_last").append(strcx); } }) $.getJSON("/weather/data/foshorttime.js", function (json) { if (json) { var shidu = json[0]["hmin"] + "% ~ " + json[0]["hmax"] + "% "; var strcontent = "
"; //strcontent += "
" + json[0]["tmax"] + "°C " + json[0]["ws"] + "
"; strcontent += "
" + json[0]["tmax"] + "°C
"; strcontent += "
"; //strcontent += "" + json[0]["tmin"] + "°C ~ " + json[0]["tmax"] + "°C " + " " + json[0]["wind"] + "
Humidity " + shidu + "
" + datetime + "
"; strcontent += "" + json[0]["tmin"] + "°C ~ " + json[0]["tmax"] + "°C " + " Humidity " + shidu + " " + datetime + ""; strcontent += "
"; strcontent += "
"; $("#foshorttime01").append(strcontent); var strcx = new Array(); strcx.push("
"); strcx.push("
"); strcx.push("
" + json[0]["ws"] + "
" + json[0]["wind"] + "
相对湿度:" + shidu + "
"); strcx.push("
"); $("#foshorttime02").append(strcx.join("")); } }) }; function Titfodaily() { $.getJSON("/weather/data/fodaily.js?t=" + Math.random(), function (json) { if (json) { var datetime = new Date(json[0]["datetime"].replace(/-/g, "/")); //转换成Data(); $("#titfodaily").append(json[0]["summary"] + "
" + json[0]["outlook"] + "
" + datetime.Format("dd/MM hh:00")); } }) }; //折线图-本地十天天气 function line_10day() { require.config({ paths: { echarts: '/Echarts/asset/js/echarts', 'echarts/chart/line': '/Echarts/asset/js/echarts-map' } }); option = { title: { text: '', subtext: '' }, tooltip: { trigger: 'axis', axisPointer: { type: 'none' } }, legend: { selectedMode: false, data: ['', ''] }, toolbox: { show: false }, calculable: false, color: ['#f9a700', '#6196ff'], grid: { x: 40, y: 25, x2: 40, y2: 20, borderWidth:0 }, xAxis: [ { type: 'category', boundaryGap: false, axisTick: { show: false }, axisLine: false, splitArea: { show: false }, splitLine: { show: false }, axisLabel: { textStyle: { color: '#fff' } }, data: time_9 } ], yAxis: [ { type: 'value', axisLabel: { show:false, formatter: '{value} °C' }, scale: true, axisLine: false, splitArea: { show: false }, splitLine: {show: false} } ], series: [ { name: 'Maximum temperature', type: 'line', itemStyle: { normal: { lineStyle: { shadowColor: 'rgba(0,0,0,0.0)' } } }, symbol: "circle", symbolSize: "2", itemStyle: { normal: { label: { show: true, textStyle: { fontSize: '12', fontFamily: 'arial', color: '#7b7b7b' } } } }, data: tmax_9, tooltip: { // Series config. trigger: 'item', formatter: "Maximum temperature:{c} ℃" } }, { name: 'Minimum temperature', type: 'line', itemStyle: { normal: { lineStyle: { shadowColor: 'rgba(0,0,0,0.0)' } } }, symbol: "circle", symbolSize: "2", itemStyle: { normal: { label: { show: true, textStyle: { fontSize: '12', fontFamily: 'arial', color: '#7b7b7b' } } } }, data: tmin_9, tooltip: { // Series config. trigger: 'item', formatter: "Minimum temperature:{c} ℃" } } ] }; require( [ 'echarts', 'echarts/chart/line' ], function (ec) { var myChart = ec.init(document.getElementById('weather_10')); myChart.setOption(option); } ) } //日期 Date.prototype.Format = function (fmt) { //author: meizz var o = { "M+": this.getMonth() + 1, //月份 "d+": this.getDate(), //日 "h+": this.getHours(), //小时 "m+": this.getMinutes(), //分 "s+": this.getSeconds(), //秒 "q+": Math.floor((this.getMonth() + 3) / 3), //季度 "S": this.getMilliseconds() //毫秒 }; if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); for (var k in o) if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); return fmt; }