myjs.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. var biaotou;
  2. var dianming;
  3. var danwei;
  4. var startTime;
  5. var endTime;
  6. function ShowDiv(show_div,bg_div){
  7. //document.getElementById(show_div).style.display='block';
  8. $("#"+show_div).attr("style","display:display");
  9. //document.getElementById(bg_div).style.display='block' ;
  10. //var bgdiv = document.getElementById(bg_div);
  11. //bgdiv.style.width = document.body.scrollWidth;
  12. //$("#"+bg_div).height($(document).height());
  13. };
  14. //关闭弹出层
  15. function CloseDiv(show_div,bg_div)
  16. {
  17. document.getElementById(show_div).style.display='none';
  18. //document.getElementById(bg_div).style.display='none';
  19. };
  20. function queryData(){
  21. var startTime=$("#startDate").val();
  22. var endTime=$("#endDate").val();
  23. var datetime=new Date();
  24. if(endTime<startTime){
  25. alert("输入的开始时间有误");
  26. return;
  27. }else if(startTime>endTime){
  28. alert("输入的开始时间有误");
  29. return;
  30. }
  31. if(startTime!=''&&endTime!=''){
  32. biaotou=$("#biaotou").val();
  33. dianming=$("#dianming").val();
  34. danwei=$("#danwei").val();
  35. highstock(startTime,endTime);
  36. }else{
  37. alert("输入非法");
  38. return;
  39. }
  40. }
  41. function queryDatafirsload(){
  42. // biaotou=$("#biaotou").val();
  43. // dianming=$("#dianming").val();
  44. // danwei=$("#danwei").val();
  45. highstock();
  46. }
  47. function highstock(startTime,endTime,code,title,unit){
  48. var seriesOptions = [],
  49. seriesCounter = 0,
  50. names = [biaotou];
  51. if(dianming==undefined || dianming=='undefined'){
  52. dianming=code;
  53. }
  54. if(biaotou==undefined || biaotou=='undefined'){
  55. biaotou=title;
  56. names = [title];
  57. }
  58. if(danwei==undefined || danwei=='undefined'){
  59. danwei=unit;
  60. }
  61. createChart = function () {
  62. $('#container').highcharts('StockChart', {
  63. legend: {
  64. enabled: true,
  65. align: 'right',
  66. backgroundColor: '#FCFFC5',
  67. borderColor: 'black',
  68. borderWidth: 2,
  69. layout: 'vertical',
  70. verticalAlign: 'top',
  71. y: 100,
  72. shadow: true
  73. },
  74. rangeSelector: {
  75. selected: 1
  76. },
  77. chart:{
  78. alignTicks:true,
  79. type:'line'
  80. },
  81. navigator :{
  82. xAxis: {
  83. type: 'datetime',
  84. labels: {
  85. align: 'center',
  86. formatter: function() {
  87. return Highcharts.dateFormat('%Y:%m:%d %H:%M:%S', this.value);
  88. }
  89. }
  90. }}
  91. ,
  92. yAxis: [{ // Primary yAxis
  93. min:0,
  94. labels: {
  95. formatter: function () {
  96. return (this.value)+danwei;
  97. },
  98. style: {
  99. color: '#89A54E'
  100. }
  101. },
  102. title: {
  103. text: biaotou+"("+danwei+")",
  104. style: {
  105. color: '#89A54E'
  106. }
  107. },opposite: false
  108. } ]
  109. ,tooltip: {
  110. pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b> <br/>',
  111. valueDecimals: 2
  112. },
  113. series: seriesOptions
  114. }
  115. );
  116. };
  117. 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));
  118. //$.each(names, function (i, name) {
  119. $.getJSON(encodeURI(encodeURI(b)),function (data) {
  120. dianming=data[1];
  121. biaotou=data[2];
  122. danwei=data[3];
  123. startTime=data[4];
  124. endTime=data[5];
  125. $("#startDate").val(startTime);
  126. $("#endDate").val(endTime);
  127. seriesOptions[0] = {
  128. yAxis:0,
  129. name: biaotou,
  130. data: data[0],
  131. pointStart: startTime,
  132. pointEnd:endTime
  133. };
  134. // As we're loading the data asynchronously, we don't know what order it will arrive. So
  135. // we keep a counter and create the chart when all the data is loaded.
  136. seriesCounter += 1;
  137. if (seriesCounter === names.length) {
  138. createChart();
  139. }
  140. });
  141. //});
  142. }
  143. function init(title,code,unit){
  144. ShowDiv("MyDiv","fade");
  145. queryDatafirsload(title,code,unit);
  146. //queryData();
  147. //setTimeout(queryData,1000);
  148. }
  149. function showZB(title,code,unit){
  150. var url = encodeURI(encodeURI("/testwjw/index.action?dianming="+code+"&biaotou="+title+"&danwei="+unit));
  151. $("#myframe").attr("src",url);//.submit();
  152. dianming=code;
  153. biaotou=title;
  154. danwei=unit;
  155. shownew(title);
  156. }
  157. function shownew(title){
  158. //ShowDiv("MyDiv","fade");
  159. //queryDatafirsload();
  160. //init(title,code,unit);
  161. $("#chartContainer").dialog({
  162. title:title,
  163. resizable: false,
  164. width:1620,
  165. height:800,
  166. modal: true,
  167. buttons: {
  168. "关闭": function() {
  169. $(this).dialog( "close" );
  170. }
  171. }
  172. });
  173. }