main.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. var chart1;
  2. var chart2;
  3. var options1;
  4. var options2;
  5. Highcharts.setOptions( {
  6. global : {
  7. useUTC : false
  8. }
  9. });
  10. options1 = {
  11. chart : {
  12. renderTo : 'container1'
  13. },
  14. title : {
  15. text : '风场绩效榜'
  16. },
  17. xAxis : [ {
  18. categories : [ '01号风机', '02号风机', '03号风机', '04号风机', '05号风机' ]
  19. }, {
  20. categories : [ '', '', '', '', '' ],
  21. opposite : true
  22. } ],
  23. yAxis : { // Primary yAxis
  24. min : 0,
  25. title : {
  26. text : ''
  27. }
  28. },
  29. legend : {
  30. align : 'center',
  31. verticalAlign : 'top',
  32. margin : 0,
  33. y : 20,
  34. reversed : true
  35. },
  36. plotOptions : {
  37. series : {
  38. stacking : 'normal'
  39. }
  40. /*,
  41. bar: {
  42. dataLabels: {
  43. enabled: true
  44. }
  45. }*/
  46. },
  47. series : [ {
  48. type : 'bar',
  49. name : '性能损失和误差',
  50. yAxis : 0,
  51. data : [],
  52. stack : '2'
  53. }, {
  54. type : 'bar',
  55. name : '受累损失',
  56. yAxis : 0,
  57. data : [],
  58. stack : '2'
  59. }, {
  60. type : 'bar',
  61. name : '限电损失',
  62. yAxis : 0,
  63. data : [],
  64. stack : '2'
  65. }, {
  66. type : 'bar',
  67. name : '非计划检修损失',
  68. yAxis : 0,
  69. data : [],
  70. stack : '2'
  71. }, {
  72. type : 'bar',
  73. name : '计划检修损失',
  74. yAxis : 0,
  75. data : [],
  76. stack : '2'
  77. }, {
  78. type : 'bar',
  79. name : '实发电量',
  80. yAxis : 0,
  81. data : [],
  82. stack : '2'
  83. }, {
  84. type : 'bar',
  85. name : '理论电量',
  86. yAxis : 0,
  87. data : [],
  88. stack : '3'
  89. }, {
  90. type : 'line',
  91. inverted : true,
  92. xAxis : 1,
  93. yAxis : 0,
  94. color : '#000000',
  95. name : ' ',
  96. data : []
  97. } ]
  98. };
  99. options2 = {
  100. colors: [
  101. '#00B259', //绿
  102. '#B20000', //红
  103. '#006DD9', //蓝
  104. '#000000', //黑
  105. '#FFBFFF',//藕荷色
  106. '#FF8000'//橘黄
  107. ],
  108. chart: {
  109. renderTo: 'container2',
  110. type: 'spline',
  111. //backgroundColor:'#BFDFFF',
  112. //plotBackgroundColor:'#BFDFFF',
  113. zoomType: 'x',
  114. events: {
  115. }
  116. },
  117. title: {
  118. text: '风电历史功率'
  119. },
  120. subtitle: {
  121. text: ''
  122. },
  123. xAxis: {
  124. labels: {
  125. align: 'center',
  126. formatter: function() {
  127. return Highcharts.dateFormat('%H<br/>%M', this.value);
  128. }
  129. },
  130. type: 'datetime'
  131. },
  132. yAxis: [{
  133. title: {
  134. text: '功率数值(MW)'
  135. }
  136. },{
  137. title:{
  138. text :'风速(m/s)'
  139. },
  140. labels:{
  141. formatter: function(){
  142. return this.value;
  143. }
  144. },
  145. lineWidth : 1,
  146. opposite:true
  147. }],
  148. legend: {
  149. layout: 'vertical',
  150. // backgroundColor: '#FFFFFF',
  151. align: 'right',
  152. verticalAlign: 'top',
  153. floating: true
  154. // shadow: true
  155. // layout: 'vertical',
  156. // align: 'right',
  157. // verticalAlign: 'middle',
  158. // borderWidth: 0
  159. },
  160. tooltip: {
  161. crosshairs:{//控制十字线
  162. width:2
  163. },
  164. shared:true,
  165. xDateFormat:'%Y-%m-%d %H:%M'
  166. /*formatter: function() {
  167. return '<b>'+ this.series.name +'</b>:'+
  168. Highcharts.numberFormat(this.y, 2) +' 万kW<br/>时间:'+
  169. Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x);
  170. }*/
  171. },
  172. credits: {
  173. enabled: false
  174. },
  175. plotOptions: {
  176. spline: {
  177. dataLabels : {
  178. enabled :false
  179. },
  180. // pointPadding: 0.2,
  181. borderWidth: 0
  182. },
  183. series: {
  184. cursor: 'pointer',
  185. marker: {
  186. radius: 0,
  187. symbol: 'circle' //曲线点类型:"circle", "square", "diamond", "triangle","triangle-down",默认是"circle"
  188. }
  189. }
  190. },
  191. series: [{
  192. type: 'spline',
  193. name: '应发功率(单位:MW)',
  194. yAxis:0
  195. },
  196. {
  197. type: 'spline',
  198. name: '实发功率(单位:MW)',
  199. yAxis:0
  200. },
  201. {
  202. type: 'spline',
  203. name: '理论功率(单位:MW)',
  204. yAxis:0
  205. },
  206. {
  207. type: 'spline',
  208. name: '预测功率(单位:MW)',
  209. yAxis:0
  210. },
  211. {
  212. type: 'spline',
  213. name: '保证功率(单位:MW)',
  214. yAxis:0
  215. },{
  216. type: 'spline',
  217. name: '平均风速',
  218. yAxis:1
  219. }]
  220. };
  221. function getResultInfo(res) {
  222. if (res["sfdl"] != null) {
  223. var yfdl = [];
  224. var sfdl = [];
  225. var gzdl = [];
  226. var whdl = [];
  227. var xddl = [];
  228. var qfdl = [];
  229. var sldl = [];
  230. var names = [];
  231. var names2 = [];
  232. $.each(res["names"], function(m, obj) {
  233. names.push(obj);
  234. });
  235. $.each(res["names2"], function(m, obj) {
  236. names2.push(obj);
  237. });
  238. $.each(res["yfdl"], function(m, obj) {
  239. yfdl.push(parseFloat(obj));
  240. });
  241. $.each(res["sfdl"], function(m, obj) {
  242. sfdl.push(parseFloat(obj));
  243. });
  244. $.each(res["gzdl"], function(m, obj) {
  245. gzdl.push(parseFloat(obj));
  246. });
  247. $.each(res["whdl"], function(m, obj) {
  248. whdl.push(parseFloat(obj));
  249. });
  250. $.each(res["xddl"], function(m, obj) {
  251. xddl.push(parseFloat(obj));
  252. });
  253. $.each(res["qfdl"], function(m, obj) {
  254. qfdl.push(parseFloat(obj));
  255. });
  256. $.each(res["sldl"], function(m, obj) {
  257. sldl.push(parseFloat(obj));
  258. });
  259. var num = names.length;
  260. options1.series[0].data = qfdl;
  261. options1.series[1].data = sldl;
  262. options1.series[2].data = xddl;
  263. options1.series[3].data = gzdl;
  264. options1.series[4].data = whdl;
  265. options1.series[5].data = sfdl;
  266. options1.series[6].data = yfdl;
  267. options1.series[7].data = yfdl;
  268. options1.xAxis[0].categories = names;
  269. options1.xAxis[1].categories = names2;
  270. } else {
  271. options1.series[0].data = [];
  272. options1.series[1].data = [];
  273. options1.series[2].data = [];
  274. options1.series[3].data = [];
  275. options1.series[4].data = [];
  276. options1.series[5].data = [];
  277. options1.series[6].data = [];
  278. options1.series[7].data = [];
  279. options1.xAxis[0].categories = [];
  280. options1.xAxis[1].categories = [];
  281. }
  282. chart1 = new Highcharts.Chart(options1);
  283. }
  284. function historyApdata(){
  285. var url = "historyAjax.action";
  286. $.ajax({
  287. url : url,
  288. type : "post",
  289. cache : false,
  290. dataType : "json",
  291. data : {},
  292. ifModified : false,
  293. success : function(result) {
  294. var yfgl = [];
  295. var sjgl = [];
  296. var lvgl = [];
  297. var ycgl = [];
  298. var bzgl = [];
  299. var pjfs = [];
  300. var xtime=[];
  301. var index=0;
  302. var count=0;
  303. $.each(result, function(m, obj) {
  304. //if(m == result.length -1){
  305. if(index<obj.value7){
  306. index++;
  307. ycgl.push( parseFloat(obj.value4) );
  308. }
  309. if(count<obj.value8){
  310. yfgl.push( parseFloat(obj.value1) );
  311. sjgl.push( parseFloat(obj.value2) );
  312. lvgl.push( parseFloat(obj.value3) );
  313. bzgl.push( parseFloat(obj.value5) );
  314. pjfs.push( parseFloat(obj.value6) );
  315. count++;
  316. }
  317. xtime.push(parseFloat(obj.time));
  318. });
  319. options2.series[0].data = yfgl;
  320. options2.series[1].data = sjgl;
  321. options2.series[2].data = lvgl;
  322. options2.series[3].data = ycgl;
  323. options2.series[4].data = bzgl;
  324. options2.series[5].data = pjfs;
  325. options2.xAxis.categories = xtime;
  326. chart2 = new Highcharts.Chart(options2);
  327. }
  328. });
  329. }
  330. function queryApDataAll() {
  331. $.ajax({
  332. url : "queryPowerAll.action",
  333. type : "post",
  334. cache : false,
  335. dataType : "json",
  336. data : {},
  337. ifModified : false,
  338. success : function(result) {
  339. getResultInfo(result);
  340. }
  341. });
  342. }
  343. $(document).ready(function() {
  344. queryApDataAll();
  345. historyApdata();
  346. showJqGrid1();
  347. showJqGrid2();
  348. });