var layer; var chartLine; $(function() { layui.use([ 'layer', 'laydate', 'form' ], function() { var form = layui.form; // 只有执行了这一步,部分表单元素才会自动修饰成功 layer = layui.layer; layDate = layui.laydate; form.render(); // 日期 layDate.render({ elem : '#start' }); // 日期 layDate.render({ elem : '#end' }); }); // 根据页面自动计算余下款低-选择框的高度 var bodyHeight = window.innerHeight; var headerHeight = $("#header-condition").height(); $("#container").css("height", bodyHeight - headerHeight - 40); // 初始化显示走势图 chartLine = initChartLine(); }); // 执行查询 function query() { var data = {}; var t = $('#form-query').serializeArray(); $.each(t, function() { data[this.name] = this.value; }); var index = layer.load(0); $.ajax({ type : "POST", url : "../../basic/gas/list-chart", dataType : "json", contentType : "application/json;charset=UTF-8", data : JSON.stringify(data), success : function(result) { layer.close(index); if(result){ renderChart(result); }else{ layer.msg("没有获取到检测结果信息!"); } }, error : function(result) { layer.close(index); layer.msg("获取数据失败,请重新尝试!"); } }); }; function renderChart(result) { var txt = $("#depotId").find("option:selected").text(); chartLine.option.title.text = txt + "气体检测走势"; chartLine.option.xAxis[0].data = result.listDate; chartLine.option.series[0].data = result.o2Ave; chartLine.option.series[1].data = result.o2Max; chartLine.option.series[2].data = result.o2Min; chartLine.option.series[3].data = result.n2Ave; chartLine.option.series[4].data = result.n2Max; chartLine.option.series[5].data = result.n2Min; chartLine.option.series[6].data = result.co2Ave; chartLine.option.series[7].data = result.co2Max; chartLine.option.series[8].data = result.co2Min; chartLine.option.series[9].data = result.ph3Ave; chartLine.option.series[10].data = result.ph3Max; chartLine.option.series[11].data = result.ph3Min; chartLine.chart.setOption(chartLine.option, true); }; function initChartLine() { var option = { title : { text : '气体检测走势', show : true }, tooltip : { trigger : 'axis', axisPointer : { type : 'cross', label : { backgroundColor : '#6a7985' } } }, color : [ '#FF00FF', '#0000FF', '#00FFFF', '#00FF00', '#FFFF00', '#FF7D00', '#FF0000', '#4472C5', '#ED7C30', '#80FF80', '#FF8096', '#800080' ], legend : { data : [ 'O2最高', 'O2平均', 'O2最低', 'CO2最高', 'CO2平均', 'CO2最低', 'PH3最高', 'PH3平均', 'PH3最低', 'N2最高', 'N2平均', 'N2最低' ], bottom : '10', top : 'bottom', selected : { 'O2最高' : false, 'O2平均' : true, 'O2最低' : false, 'CO2最高' : false, 'CO2平均' : true, 'CO2最低' : false, 'PH3最高' : false, 'PH3平均' : true, 'PH3最低' : false, 'N2最高' : false, 'N2平均' : true, 'N2最低' : false, } }, grid : { left : '3%', right : '3%', bottom : '3%', containLabel : true }, xAxis : [ { data : [ '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00' ] } ], yAxis : [ { name : 'O2/N2 气体单位(%)', type : 'value' }, { name : 'PH3/CO2 气体单位(PPM)', type : 'value' } ], series : [ { name : 'O2平均', type : 'line', itemStyle : { normal : { color : '#FF7D00', borderColor : '#FF7D00' } }, data : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] }, { name : 'O2最低', type : 'line', itemStyle : { normal : { color : '#0000FF', borderColor : '#0000FF' } }, data : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] }, { name : 'O2最高', type : 'line', itemStyle : { normal : { color : '#00FFFF', borderColor : '#00FFFF' } }, data : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] }, { name : 'N2平均', type : 'line', itemStyle : { normal : { color : '#FF7D00', borderColor : '#FF7D00' } }, data : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] }, { name : 'N2最低', type : 'line', itemStyle : { normal : { color : '#0000FF', borderColor : '#0000FF' } }, data : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] }, { name : 'N2最高', type : 'line', itemStyle : { normal : { color : '#00FFFF', borderColor : '#00FFFF' } }, data : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] }, { name : 'CO2最高', type : 'line', yAxisIndex : 1, itemStyle : { normal : { color : '#00FF00', borderColor : '#00FF00' } }, data : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] }, { name : 'CO2平均', type : 'line', yAxisIndex : 1, itemStyle : { normal : { color : '#FF0000', borderColor : '#FF0000' } }, data : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] }, { name : 'CO2最低', type : 'line', yAxisIndex : 1, itemStyle : { normal : { color : '#FF00FF', borderColor : '#FF00FF' } }, data : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] }, { name : 'PH3最高', type : 'line', yAxisIndex : 1, itemStyle : { normal : { color : '#FFFF00', borderColor : '#FFFF00' } }, data : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] }, { name : 'PH3平均', type : 'line', yAxisIndex : 1, itemStyle : { normal : { color : '#000000', borderColor : '#000000' } }, data : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] }, { name : 'PH3最低', yAxisIndex : 1, type : 'line', itemStyle : { normal : { color : '#4472C5', borderColor : '#4472C5' } }, data : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] } ] }; var myChart = echarts.init(document.getElementById("container"), "light"); myChart.setOption(option, true); return { "chart" : myChart, "option" : option }; };