power.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. 
  2. var chart1;
  3. var options1;
  4. Highcharts.setOptions({
  5. global : {
  6. useUTC : false
  7. }
  8. });
  9. String.prototype.endWith=function(oString){
  10. var reg=new RegExp(oString+"$");
  11. return reg.test(this);
  12. }
  13. options1= {
  14. colors: [
  15. '#00B259', //绿
  16. '#B20000', //红
  17. '#006DD9', //蓝
  18. '#000000', //黑
  19. '#FFBFFF',//藕荷色
  20. '#FF8000'//橘黄
  21. ],
  22. chart: {
  23. renderTo: 'container1',
  24. type: 'spline',
  25. //backgroundColor:'#BFDFFF',
  26. //plotBackgroundColor:'#BFDFFF',
  27. zoomType: 'x',
  28. events: {
  29. }
  30. },
  31. title: {
  32. text: '功率曲线'
  33. },
  34. subtitle: {
  35. text: ''
  36. },
  37. xAxis: {
  38. labels: {
  39. align: 'center',
  40. formatter: function() {
  41. return Highcharts.dateFormat('%H<br/>%M', this.value);
  42. }
  43. },
  44. type: 'datetime'
  45. },
  46. yAxis: [{
  47. title: {
  48. text: '功率数值(MW)'
  49. }
  50. },{
  51. title:{
  52. text :'风速(m/s)'
  53. },
  54. labels:{
  55. formatter: function(){
  56. return this.value;
  57. }
  58. },
  59. lineWidth : 1,
  60. opposite:true
  61. }],
  62. legend: {
  63. layout: 'vertical',
  64. // backgroundColor: '#FFFFFF',
  65. align: 'right',
  66. verticalAlign: 'top',
  67. floating: true
  68. // shadow: true
  69. // layout: 'vertical',
  70. // align: 'right',
  71. // verticalAlign: 'middle',
  72. // borderWidth: 0
  73. },
  74. tooltip: {
  75. crosshairs:{//控制十字线
  76. width:2
  77. },
  78. shared:true,
  79. xDateFormat:'%Y-%m-%d %H:%M'
  80. /*formatter: function() {
  81. return '<b>'+ this.series.name +'</b>:'+
  82. Highcharts.numberFormat(this.y, 2) +' 万kW<br/>时间:'+
  83. Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x);
  84. }*/
  85. },
  86. credits: {
  87. enabled: false
  88. },
  89. plotOptions: {
  90. spline: {
  91. dataLabels : {
  92. enabled :false
  93. },
  94. // pointPadding: 0.2,
  95. borderWidth: 0
  96. },
  97. series: {
  98. cursor: 'pointer',
  99. marker: {
  100. radius: 0,
  101. symbol: 'circle' //曲线点类型:"circle", "square", "diamond", "triangle","triangle-down",默认是"circle"
  102. }
  103. }
  104. },
  105. series: [{
  106. type: 'spline',
  107. name: '应发功率(单位:MW)',
  108. yAxis:0
  109. },
  110. {
  111. type: 'spline',
  112. name: '实发功率(单位:MW)',
  113. yAxis:0
  114. },
  115. {
  116. type: 'spline',
  117. name: '理论功率(单位:MW)',
  118. yAxis:0
  119. },
  120. {
  121. type: 'spline',
  122. name: '预测功率(单位:MW)',
  123. yAxis:0
  124. },
  125. {
  126. type: 'spline',
  127. name: '保证功率(单位:MW)',
  128. yAxis:0
  129. },{
  130. type: 'spline',
  131. name: '平均风速',
  132. yAxis:1
  133. }]
  134. };
  135. function apdata(){
  136. var wpId=$("#wpId").val();
  137. var url = "/wpmonitor/windfarmpower.action?wpId="+wpId;
  138. $.ajax({
  139. url : url,
  140. type : "post",
  141. cache : false,
  142. dataType : "json",
  143. data : {},
  144. ifModified : false,
  145. success : function(result) {
  146. var yfgl = [];
  147. var sjgl = [];
  148. var lvgl = [];
  149. var ycgl = [];
  150. var bzgl = [];
  151. var pjfs = [];
  152. var xtime=[];
  153. var index=0;
  154. var count=0;
  155. $.each(result, function(m, obj) {
  156. //if(m == result.length -1){
  157. if(index<obj.value7){
  158. index++;
  159. if(obj.value4!=null)
  160. {
  161. ycgl.push( parseFloat(obj.value4) );
  162. }else
  163. {
  164. ycgl.push( null );
  165. }
  166. }
  167. if(count<obj.value8){
  168. yfgl.push( parseFloat(obj.value1) );
  169. sjgl.push( parseFloat(obj.value2) );
  170. lvgl.push( parseFloat(obj.value3) );
  171. bzgl.push( parseFloat(obj.value5) );
  172. pjfs.push( parseFloat(obj.value6) );
  173. count++;
  174. }
  175. xtime.push(parseFloat(obj.time));
  176. });
  177. options1.series[0].data = yfgl;
  178. options1.series[1].data = sjgl;
  179. options1.series[2].data = lvgl;
  180. options1.series[3].data = ycgl;
  181. options1.series[4].data = bzgl;
  182. options1.series[5].data = pjfs;
  183. options1.xAxis.categories = xtime;
  184. chart1 = new Highcharts.Chart(options1);
  185. }
  186. });
  187. }