var currDate = new Date(); var yesterdayDate = new Date(); $(function () { if (todayData_UVI.length == 0 && yesterdayData_UVI.length == 0) { $("#main").append("
设备故障维修中,紫外线资料没能及时提供,不便之处,敬请原谅。
") $(".uivEc").hide(); } else { DrLine(); } }) function DrLine(){ if( location.pathname == "/wap/UVI.aspx" && xAxisLable.length > 0 ){ var lastHour = xAxisLable[xAxisLable.length-1].split(":")[0]; var startHour = parseInt(lastHour) - 6 > 0 ? parseInt(lastHour) - 6 : parseInt(lastHour) + 24 - 6; var startTime = startHour + ":" + xAxisLable[xAxisLable.length-1].split(":")[1]; if ( startHour < 10 ){ startTime = "0" + startTime; } var startIndex = 0; $(xAxisLable).each(function(index,item){ if( item == startTime){ startIndex = index; return false; } }); if( startIndex > 0 ){ xAxisLable.splice(0,startIndex); yesterdayData_UVI.splice(0,startIndex); todayData_UVI.splice(0,startIndex); } } require.config({ paths: { echarts: '/Echarts/asset/js/echarts', 'echarts/chart/line': '/Echarts/asset/js/echarts-map' } }); option = { height:200, tooltip: { show: true, trigger: 'axis' }, grid: { x: 30, y: 30, x2: 50, y2: 30 }, xAxis: [ { type: 'category', axisLine: { // 轴线 show: true, lineStyle: { color: '#636363', type: 'solid', width: 2 } }, axisTick: { show: false }, splitLine: { show: false, lineStyle: { color: '#fff', type: 'solid', width: 1 } }, splitArea: { show: false, areaStyle: { color: ['#B2CEDA', '#B1C6DB', '#B1BFDA', '#B1B7DB', '#B1B0DC', '#B1B0DC', '#B1A7DB', '#B19FDB', '#B297DC', '#B090DB', '#B288DC', '#B180DB', '#B177DB', '#B270DC', '#B269DC', '#B161DC'] } }, data: xAxisLable, axisLabel: { show: true, interval: 59 // {number} } } ], yAxis: [ { type: 'value', splitNumber: 15, max: 15, axisLabel: { formatter: ' ' }, axisLine: { // 轴线 show: true, lineStyle: { color: '#636363', type: 'solid', width: 2 } }, splitLine: { show: true, lineStyle: { color: ['', '#98B6CF', '#99ACCF', '#99A6D2', '#9796CF', '#988ED0', '#A596D5', '#916ECD', '#A88AD7', '#A77DD8', '#A570D4', '#A570D4', '#A25BD1', '#983AD1', '#962BCF'], type: 'solid', width: 2 } }, splitArea: { show: true, areaStyle: { color: ['#B2CEDA', '#B1C6DB', '#B1BFDA', '#B1B7DB', '#B1B0DC', '#B1B0DC', '#B1A7DB', '#B19FDB', '#B297DC', '#B090DB', '#B288DC', '#B180DB', '#B177DB', '#B270DC', '#B269DC', '#B161DC'] } } }, { //y 第二组数 type: 'value', precision: 1, splitNumber: 5, max: 5, min: 1, axisLabel: { formatter: function (value) { // Function formatter var t = ""; switch (value) { case 1: t = "(最弱)"; break; case 2: t = "(最弱)"; break; case 3: t = "(中等)"; break; case 4: t = "(强)"; break; case 5: t = "(很强)"; break; } return value + ' 级\n' + t; } }, axisLine: { // 轴线 show: true, lineStyle: { color: '#636363', type: 'solid', width: 2 } }, splitLine: { show: true, lineStyle: { color: ['#636363', '#99A6D2', '#957FCF', '#9C6DD3', '#9743CE'], type: 'solid', width: 2 } } } ], series: [ { name: new Date(yesterdayDate.setDate(yesterdayDate.getDate() - 1)).format('MM月dd日'), type: 'line', symbol: 'none', itemStyle: { normal: { color: '#FFFF01', lineStyle: { shadowColor: 'rgba(0,0,0,0.4)' } } }, data: yesterdayData_UVI }, { name: currDate.format('MM月dd日'), type: 'line', symbol: 'none', itemStyle: { normal: { color: '#FE0000', lineStyle: { shadowColor: 'rgba(0,0,0,0.4)' } } }, data: todayData_UVI } ] }; require( [ 'echarts', 'echarts/chart/line' ], function (ec) { var myChart = ec.init(document.getElementById('main')); myChart.setOption(option); } ) }