var biaotou; var dianming; var danwei; var startTime; var endTime; function ShowDiv(show_div,bg_div){ //document.getElementById(show_div).style.display='block'; $("#"+show_div).attr("style","display:display"); //document.getElementById(bg_div).style.display='block' ; //var bgdiv = document.getElementById(bg_div); //bgdiv.style.width = document.body.scrollWidth; //$("#"+bg_div).height($(document).height()); }; //关闭弹出层 function CloseDiv(show_div,bg_div) { document.getElementById(show_div).style.display='none'; //document.getElementById(bg_div).style.display='none'; }; function queryData(){ var startTime=$("#startDate").val(); var endTime=$("#endDate").val(); var datetime=new Date(); if(endTimeendTime){ alert("输入的开始时间有误"); return; } if(startTime!=''&&endTime!=''){ biaotou=$("#biaotou").val(); dianming=$("#dianming").val(); danwei=$("#danwei").val(); highstock(startTime,endTime); }else{ alert("输入非法"); return; } } function queryDatafirsload(){ // biaotou=$("#biaotou").val(); // dianming=$("#dianming").val(); // danwei=$("#danwei").val(); highstock(); } function highstock(startTime,endTime,code,title,unit){ var seriesOptions = [], seriesCounter = 0, names = [biaotou]; if(dianming==undefined || dianming=='undefined'){ dianming=code; } if(biaotou==undefined || biaotou=='undefined'){ biaotou=title; names = [title]; } if(danwei==undefined || danwei=='undefined'){ danwei=unit; } createChart = function () { $('#container').highcharts('StockChart', { legend: { enabled: true, align: 'right', backgroundColor: '#FCFFC5', borderColor: 'black', borderWidth: 2, layout: 'vertical', verticalAlign: 'top', y: 100, shadow: true }, rangeSelector: { selected: 1 }, chart:{ alignTicks:true, type:'line' }, navigator :{ xAxis: { type: 'datetime', labels: { align: 'center', formatter: function() { return Highcharts.dateFormat('%Y:%m:%d %H:%M:%S', this.value); } } }} , yAxis: [{ // Primary yAxis min:0, labels: { formatter: function () { return (this.value)+danwei; }, style: { color: '#89A54E' } }, title: { text: biaotou+"("+danwei+")", style: { color: '#89A54E' } },opposite: false } ] ,tooltip: { pointFormat: '{series.name}: {point.y}
', valueDecimals: 2 }, series: seriesOptions } ); }; var b=(startTime==undefined?('/testwjw/chaxuna.action?dianming='+dianming+'&biaotou='+biaotou+'&danwei='+ danwei):('/testwjw/chaxuna.action?dianming='+dianming+'&biaotou='+biaotou+'&danwei='+danwei+'&startTime='+startTime+'&endTime='+endTime)); //$.each(names, function (i, name) { $.getJSON(encodeURI(encodeURI(b)),function (data) { dianming=data[1]; biaotou=data[2]; danwei=data[3]; startTime=data[4]; endTime=data[5]; $("#startDate").val(startTime); $("#endDate").val(endTime); seriesOptions[0] = { yAxis:0, name: biaotou, data: data[0], pointStart: startTime, pointEnd:endTime }; // As we're loading the data asynchronously, we don't know what order it will arrive. So // we keep a counter and create the chart when all the data is loaded. seriesCounter += 1; if (seriesCounter === names.length) { createChart(); } }); //}); } function init(title,code,unit){ ShowDiv("MyDiv","fade"); queryDatafirsload(title,code,unit); //queryData(); //setTimeout(queryData,1000); } function showZB(title,code,unit){ var url = encodeURI(encodeURI("/testwjw/index.action?dianming="+code+"&biaotou="+title+"&danwei="+unit)); $("#myframe").attr("src",url);//.submit(); dianming=code; biaotou=title; danwei=unit; shownew(title); } function shownew(title){ //ShowDiv("MyDiv","fade"); //queryDatafirsload(); //init(title,code,unit); $("#chartContainer").dialog({ title:title, resizable: false, width:1620, height:800, modal: true, buttons: { "关闭": function() { $(this).dialog( "close" ); } } }); }