power.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. type: 'spline',
  126. name: '平均风速',
  127. yAxis:1
  128. }]
  129. };
  130. function apdata(){
  131. var wpId=$("#wpId").val();
  132. var timeType = $("input[name=timeStep]:checked").val();
  133. var url = "/wpmonitor/windfarmpower.action?wpId="+wpId+"&timeType="+timeType;
  134. $.ajax({
  135. url : url,
  136. type : "post",
  137. cache : false,
  138. dataType : "json",
  139. data : {},
  140. ifModified : false,
  141. success : function(result) {
  142. var yfgl = [];
  143. var sjgl = [];
  144. var lvgl = [];
  145. var ycgl = [];
  146. var bzgl = [];
  147. var pjfs = [];
  148. var xtime=[];
  149. var index=0;
  150. var count=0;
  151. $.each(result, function(m, obj) {
  152. //if(m == result.length -1){
  153. //if(index<obj.value7){
  154. //index++;
  155. if(obj.value4!=null)
  156. {
  157. ycgl.push( parseFloat(obj.value4) );
  158. }else{
  159. ycgl.push( null );
  160. }
  161. //}
  162. if(count<obj.value8){
  163. yfgl.push( parseFloat(obj.value1) );
  164. sjgl.push( parseFloat(obj.value2) );
  165. //lvgl.push( parseFloat(obj.value3) );
  166. bzgl.push( parseFloat(obj.value5) );
  167. pjfs.push( parseFloat(obj.value6) );
  168. count++;
  169. }
  170. xtime.push(parseFloat(obj.time));
  171. });
  172. options1.series[0].data = yfgl;
  173. options1.series[1].data = sjgl;
  174. options1.series[2].data = ycgl;
  175. //options1.series[2].visible=false
  176. options1.series[3].data = bzgl;
  177. options1.series[4].data = pjfs;
  178. //options1.series[5].data = lvgl;
  179. options1.xAxis.categories = xtime;
  180. chart1 = new Highcharts.Chart(options1);
  181. }
  182. });
  183. }