123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
-
- var chart1;
- var options1;
- Highcharts.setOptions({
- global : {
- useUTC : false
- }
- });
- String.prototype.endWith=function(oString){
- var reg=new RegExp(oString+"$");
- return reg.test(this);
- }
- options1= {
- colors: [
- '#00B259', //绿
- '#B20000', //红
- '#006DD9', //蓝
- '#000000', //黑
- '#FFBFFF',//藕荷色
- '#FF8000'//橘黄
- ],
- chart: {
- renderTo: 'container1',
- type: 'spline',
- //backgroundColor:'#BFDFFF',
- //plotBackgroundColor:'#BFDFFF',
- zoomType: 'x',
- events: {
-
- }
- },
- title: {
- text: '历史功率曲线'
- },
-
- subtitle: {
- text: ''
- },
- xAxis: {
- labels: {
- align: 'center',
- formatter: function() {
- return Highcharts.dateFormat('%m月<br/>%d日<br/>%H时<br/>%M分', this.value);
- }
- },
- type: 'datetime'
- },
- yAxis: [{
- title: {
- text: '功率数值(MW)'
- }
- },{
- title:{
- text :'风速(m/s)'
- },
- labels:{
- formatter: function(){
- return this.value;
- }
- },
- lineWidth : 1,
- opposite:true
- }],
- legend: {
- layout: 'vertical',
- // backgroundColor: '#FFFFFF',
- align: 'right',
- verticalAlign: 'top',
- floating: true
- // shadow: true
- // layout: 'vertical',
- // align: 'right',
- // verticalAlign: 'middle',
- // borderWidth: 0
- },
- tooltip: {
- crosshairs:{//控制十字线
- width:2
- },
- shared:true,
- xDateFormat:'%Y-%m-%d %H:%M'
- /*formatter: function() {
- return '<b>'+ this.series.name +'</b>:'+
- Highcharts.numberFormat(this.y, 2) +' 万kW<br/>时间:'+
- Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x);
- }*/
- },
- credits: {
- enabled: false
- },
- plotOptions: {
- spline: {
- dataLabels : {
- enabled :false
- },
- // pointPadding: 0.2,
- borderWidth: 0
- },
- series: {
- cursor: 'pointer',
- marker: {
- radius: 0,
- symbol: 'circle' //曲线点类型:"circle", "square", "diamond", "triangle","triangle-down",默认是"circle"
- }
- }
- },
- series: [{
- type: 'spline',
- name: '应发功率(单位:MW)',
- yAxis:0
- },
- {
- type: 'spline',
- name: '实发功率(单位:MW)',
- yAxis:0
- },
- {
- type: 'spline',
- name: '预测功率(单位:MW)',
- yAxis:0
- },
- {
- type: 'spline',
- name: '保证功率(单位:MW)',
- yAxis:0
- },{
- type: 'spline',
- name: '平均风速',
- yAxis:1
- }]
- };
- function apdata(){
- console.log(chart1);
- if (null != chart1) {
- chart1.showLoading("查询中,请稍后..");
- }
- var wpId=$("#wpId").val();
- var beginDate = $("#beginDate").val();
- var endDate = $("#endDate").val();
- var url = "/apdata/stationHistoryPowerAjax.action?wpId="+wpId+"&beginDate="+beginDate+"&endDate="+endDate;
- if ($("#period").length > 0) {
- url = url + "&period=" + $("#period").val();
- }
- $.ajax({
- url : url,
- type : "post",
- cache : false,
- dataType : "json",
- data : {},
- ifModified : false,
- success : function(result) {
- var yfgl = [];
- var sjgl = [];
- var lvgl = [];
- var ycgl = [];
- var bzgl = [];
- var pjfs = [];
- var xtime=[];
- var index=0;
- var count=0;
- $.each(result, function(m, obj) {
- //if(m == result.length -1){
- //if(index<obj.value7){
- //index++;
- if(obj.value4!=null)
- {
- ycgl.push( parseFloat(obj.value4) );
- }else{
- ycgl.push( null );
- }
-
- //}
- if(count<obj.value8){
- yfgl.push( parseFloat(obj.value1) );
- sjgl.push( parseFloat(obj.value2) );
- //lvgl.push( parseFloat(obj.value3) );
-
- bzgl.push( parseFloat(obj.value5) );
- pjfs.push( parseFloat(obj.value6) );
- count++;
- }
- xtime.push(parseFloat(obj.time));
-
- });
- options1.series[0].data = yfgl;
- options1.series[1].data = sjgl;
- options1.series[2].data = ycgl;
- //options1.series[2].visible=false
- options1.series[3].data = bzgl;
- options1.series[4].data = pjfs;
- //options1.series[5].data = lvgl;
- options1.xAxis.categories = xtime;
- chart1 = new Highcharts.Chart(options1);
-
- }
- });
- }
|