var Obj_Limit = [];// 存当限值数组
var obj_ZjCf = [];// 存放暂降触发点数据
var obj_History = [];// 存放历史数据(一次查询更新一次)
var splitObj_History = [];// 临时存放历史数据（分段查询更新一次）
var yevent_value = [];// 最小值
var events = [];// 所有暂降事件汇总
var series_Data = [];// 展示数据
var series_Nav = [];// 导航栏
var colo = [];// 颜色
var titleName = null;// 图形标题名称
var objdata = [];
var idea;

var allstime = window.parent.document.getElementById("allstime").value;
var alletime = window.parent.document.getElementById("alletime").value;
var lineIndex = window.parent.document.getElementById("lineIndex").value;
var checkpieces = window.parent.document.getElementById("checkpieces").value;
var checkpiecee = window.parent.document.getElementById("checkpiecee").value;
var allstartTime,allendTime;
var dateSilderObj;
//创建时间横轴提供用户选择时间节点
//月份定义
var Months = ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"];
function createTime(){
	$("#startTime").removeProp("disabled");
	$("#endTime").removeProp("disabled");
	$.ajax({
		type:'post',
		url:'/pqs9000/device/getSETime',
		data:{
			lineIndex:lineIndex
		},
		success:function(data){
			if(data.code === 500){
				layer.msg(data.message, {
					icon : 2,
					time : 2000
				}, function() {
					$("#point").attr("style","display:true;");
					$("#main").attr("style","display:none;");
				});
			}else{
				$("#main").attr("style","display:true;");
				$(".container-fluid").attr("style","display:true;");
				$("#point").attr("style","display:none;");

				var Sliderwidth = $("body").width()-685;
				$("#container").css("width", Sliderwidth);
				var times = data.body;
				var timeseries = [];
				if(times.length>1){
					for(var i = 0;i<times.length;i++){
						var desc;
						allstartTime = data.body[i].startTime;
						allendTime = data.body[i].endTime;
						desc = timestampToTime(allstartTime)+'-'+timestampToTime(allendTime);
						timeseries.push({name:desc,data:[allstartTime,allendTime],x:allstartTime});
					}

					if(checkpieces != null && checkpieces != "" && checkpiecee != null && checkpiecee != ""){
						creatGroups(timeseries);
						if(allstime != null && allstime != "" && alletime != null && alletime != ""){
						    creatSlider(parseInt(checkpieces),parseInt(checkpiecee),parseInt(allstime),parseInt(alletime));
						}else{
						    creatSlider(parseInt(checkpieces),parseInt(checkpiecee),allstartTime,allendTime);
						}
					}else{
						creatGroups(timeseries);
						if(allstime != null && allstime != "" && alletime != null && alletime != ""){
						    creatSlider(allstartTime,allendTime,parseInt(allstime),parseInt(alletime));
						}else{
						    creatSlider(allstartTime,allendTime,allstartTime,allendTime);
						}
					}
				}else{
					$("#timegroup").attr("style","display:none;");
					allstartTime = data.body[0].startTime;
					allendTime = data.body[0].endTime;

					if(checkpieces != null && checkpieces != "" && checkpiecee != null && checkpiecee != ""){
						if(allstime != null && allstime != "" && alletime != null && alletime != ""){
						    creatSlider(parseInt(checkpieces),parseInt(checkpiecee),parseInt(allstime),parseInt(alletime));
						}else{
						    creatSlider(parseInt(checkpieces),parseInt(checkpiecee),allstartTime,allendTime);
						}
					}else{
						if(allstime != null && allstime != "" && alletime != null && alletime != ""){
						    creatSlider(allstartTime,allendTime,parseInt(allstime),parseInt(alletime));
						}else{
						    creatSlider(allstartTime,allendTime,allstartTime,allendTime);
						}
					}
				}

				loadPloy();
				loadReport();
			}
		}
	})

}

function creatGroups(timeseries){
	Highcharts.chart('container', {
		chart: {
			type: 'timeline',
			margin: [0, 0, 0, 0]
		},
		xAxis: {
			visible: false
		},
		yAxis: {
			visible: false
		},
		credits: {
            enabled:false
        },
        colors:[guowang],
        exporting: {
            enabled:false
        },
		title: {
			text:null
		},
		toolbox:{
			show:false
		},
		plotOptions: {
			series: {
				cursor: 'timeline',
				dataLabels: {
					enabled: false
				},
				events: {
					click: function(e) {//点击图上的值时会调用。this为series
						creatSlider(e.point.data[0],e.point.data[1]);
				        window.parent.document.getElementById("checkpieces").value=e.point.data[0];
				        window.parent.document.getElementById("checkpiecee").value=e.point.data[1];
					}
				}
			}
		},
		series: [{
			data: timeseries
		}]
	});
}

function creatSlider(allstartTime,allendTime,astime,aetime){
    $("#dateSlider").empty();
	var	date = $("<div id='date' />").appendTo($("#dateSlider"));//渲染日期组件
    var step = 100/((allendTime-allstartTime)/(24*60*60*1000));
    dateSilderObj=date.dateRangeSlider({
        arrows:false,//是否显示左右箭头
        bounds: {min: new Date(allstartTime), max: new Date(allendTime)},//最大 最少日期
        defaultValues: {min: new Date(astime), max: new Date(aetime)}//默认选中区域
        ,scales:[{
            first: function(value){return value; },
            end: function(value) {return value; },
            next: function(val){
                var next = new Date(val);
                return new Date(next.setMonth(next.getMonth() + 1));
            },
            label: function(val){
                return Months[val.getMonth()];
            },
            format: function(tickContainer, tickStart, tickEnd){
                tickContainer.addClass("myCustomClass");
            }
        }]
    });//日期控件
    //重新赋值（整个时间轴）
    dateSilderObj.dateRangeSlider("bounds", new Date(allstartTime), new Date(allendTime));
    laydate.render({
    	  elem: '#startTime'
    	  ,min: timestampToTime(allstartTime)
    	  ,max: timestampToTime(allendTime)
		  ,type: 'datetime'
		  ,done: function(value, date, endDate){
	        var chas = new Date(value);
	        var chae = new Date($('#endTime').val());
	        dateSilderObj.dateRangeSlider("values", chas,chae);
		  }
    	});
    laydate.render({
  	  elem: '#endTime'
  	  ,min: timestampToTime(allstartTime)
  	  ,max: timestampToTime(allendTime)
	  ,type: 'datetime'
	  ,done: function(value, date, endDate){
        var chae = new Date(value);
        var chas = new Date($('#startTime').val());
        dateSilderObj.dateRangeSlider("values", chas,chae);
	  }
  	});

    //重新赋值（选中区域）
    dateSilderObj.dateRangeSlider("values", new Date(astime), new Date(aetime));
    $("#startTime").val(timestampToTime(astime));
    $("#endTime").val(timestampToTime(aetime));
	var startdate = new Date(allstartTime);// 时间戳为10位需*1000，时间戳为13位的话不需乘1000
	var enddate = new Date(allendTime);// 时间戳为10位需*1000，时间戳为13位的话不需乘1000

    //拖动完毕后的事件
    dateSilderObj.bind("valuesChanged", function(e, data){
        var val=data.values;
        var min = val.min.getTime();
        var max = val.max.getTime();
        var stime=val.min.getFullYear()+"-"+change(val.min.getMonth()+1)+"-"+change(val.min.getDate())+' '+change(val.min.getHours())+':'+
        	change(val.min.getMinutes())+':'+change(val.min.getSeconds());
        var etime=val.max.getFullYear()+"-"+change(val.max.getMonth()+1)+"-"+change(val.max.getDate())+' '+change(val.max.getHours())+':'+
    		change(val.max.getMinutes())+':'+change(val.max.getSeconds());

        $("#startTime").val(stime);
        $("#endTime").val(etime);
        window.parent.document.getElementById("allstime").value=min;
        window.parent.document.getElementById("alletime").value=max;

    });

}

function timestampToTime(timestamp) {
	var date = new Date(timestamp);// 时间戳为10位需*1000，时间戳为13位的话不需乘1000
	var Y = date.getFullYear() + '-';
	var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date
			.getMonth() + 1)
			+ '-';
	var D = change(date.getDate());

	var H = change(date.getHours());
	var m = change(date.getMinutes());
	var S = change(date.getSeconds());
	return Y + M + D + ' ' + H + ':' + m + ':' + S;
}

function timestampToDAY(timestamp) {
	var date = new Date(timestamp);// 时间戳为10位需*1000，时间戳为13位的话不需乘1000
	var Y = date.getFullYear() + '-';
	var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date
			.getMonth() + 1)
			+ '-';
	var D = change(date.getDate());

	var H = change(date.getHours());
	var m = change(date.getMinutes());
	var S = change(date.getSeconds());
	return Y + M + D;
}

function timestampToSECOND(timestamp) {
	var date = new Date(timestamp);// 时间戳为10位需*1000，时间戳为13位的话不需乘1000
	var Y = date.getFullYear() + '-';
	var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date
			.getMonth() + 1)
			+ '-';
	var D = change(date.getDate());

	var H = change(date.getHours());
	var m = change(date.getMinutes());
	var S = change(date.getSeconds());
	return H + ':' + m + ':' + S;
}

function change(t) {
	if (t < 10) {
		return "0" + t;
	} else {
		return t;
	}
}
$(document).ready(function() {
	if(lineIndex==null || lineIndex == ""){
		return;
	}
	createTime();
})

function loadPloy(){
	$.ajax({
		type:"POST",
		dataType:"json",
		url:"/pqs9000/devicereport/loadOffPloy",
		success:function(data){
			if(data.code == 500 || data.body == null){
				var option = $("<option selected value='0'>"
						+ data.message + "</option>");
				$("#template").append(option);
				document.getElementById("saveReport").disabled=true;
			}else{
				var modelList = data.body;
				$.each(modelList, function(i, item) {
					if(i==0){
						var option = $("<option selected value='"
								+ item.modelIndex + "'>"
								+ item.modelName + "</option>");
						$("#template").append(option);
					}else{
						var option = $("<option value='"
								+ item.modelIndex + "'>"
								+ item.modelName + "</option>");
						$("#template").append(option);
					}
				})
				document.getElementById("saveReport").disabled=false;
			}
		}
	})
}

function loadReport(){
	var heightTemp=screen.height;
	var length;
	if(heightTemp==768){
		length=8;
	}else{
		length=11;
	}
	$.ajax({
		method : "post",
		url : "/pqs9000/devicereport/loadReportInfo",
		data : {},
        error:function(data) {
        	layer.msg("获取报告列表失败", {
				icon : 2,
				time : 2000
			});
        },
		success : function(data) {
			var info = JSON.parse(data);
			var table=$('#nodelist').DataTable({
				scrollX : true,
				lengthChange : false,
				destroy : true,
				searching: false,
				"order": [ 3, 'desc' ],
				language : {
					url: '/pqs9000/json/chine.json'
				},
				pageLength:length,
				columns:[
                    {"width": "0%"},
                    {"width": "22%"},
                    {"width": "8%"},
                    {"width": "14%"},
                    {"width": "8%"},
                    {"width": "8%"},
                    {"width": "40%"}],
				data : info,
			    "columnDefs" : [ {
			        "targets": 0,
			        "visible": false,
			        "searchable": false
			      },{
//				    // 定义操作列,######以下是重点########
			    	"targets" : 6,//操作按钮目标列
				    "data" : null,
				    "orderable" : false,
			    	"render" : function(row) {
						return null;
			    	}
				    }],
			    "createdRow": function ( row, data, index ) {
		            if (data[1].length > 20) {
		                var realValue = data[1];
		                var s = data[1].substr(0, 20) + '...'
		                $('td', row).eq(0).prevObject[0].innerHTML = "<span title='" + realValue + "'>" + s + "</span>";
		            }
			    	$btnDow = $('<button type="button" class="btn themeBGColor glyphicon glyphicon-download-alt btn_dow" id="btn_dow" style="margin-left:10px">原始报告下载</button>');
			    	$btnDowUp = $('<button type="button" class="btn themeBGColor glyphicon glyphicon-download-alt btn_dowup" id="btn_dowup" style="margin-left:10px">更新报告下载</button>');
			    	$btnMod = $('<button type="button" class="btn themeBGColor glyphicon glyphicon-upload btn_mod" id="btn_mod" style="margin-left:10px">更新报告上传</button>');
			    	$btnExp = $('<button type="button" class="btn btn-danger glyphicon glyphicon-trash btn_exp" id="btn_exp" style="margin-left:10px">删除</button>');
				    $('td', row).eq(5).append($btnDow,$btnMod,$btnDowUp,$btnExp);
			    },
			    'fnDrawCallback': function(table) {
				    $("#nodelist_paginate").append("<div style='float:right;padding-top:4px;padding-left:10px'>到第 <input type='text' id='changePage' class='input-text' style='width:50px;height:28px;'> 页  <button class='btn btn-primary' id='dataTable-btn'>确定</button></div>");
				    var oTable = $("#nodelist").dataTable();
				    $('#dataTable-btn').click(function(e) {
				        if($("#changePage").val() && $("#changePage").val() > 0) {
				            var redirectpage = $("#changePage").val() - 1;
				        } else {
				            var redirectpage = 0;
				        }
				        oTable.fnPageChange(redirectpage);
				    });
				}
			});

			table.buttons().container().css("display","inline-block");
			table.buttons().container().css("float","right");
			table.buttons().container().find("a").prepend("<i class='glyphicon glyphicon-share'></i>");
			table.buttons().container().appendTo('.header');

		}
	});
}

$("#saveReport").click(function(){
	layer.confirm('报告生成耗时较久,确认生成？',function(){
		idea = ityzl_SHOW_LOAD_DOWNLOAD();
		getData("相电压有效值","1","11","最大值");
		getData("相电压有效值","2","11","最小值");
		getData("相电压有效值","0","11","平均值");
		getData("相电压有效值","3","11","CP95");

//		getData("三相电压不平衡度","1","15","最大值");
//		getData("三相电压不平衡度","2","15","最小值");
//		getData("三相电压不平衡度","0","15","平均值");
//		getData("三相电压不平衡度","3","15","CP95");

//		getData("电压总谐波畸变率","1","17","最大值");
//		getData("电压总谐波畸变率","2","17","最小值");
//		getData("电压总谐波畸变率","0","17","平均值");
//		getData("电压总谐波畸变率","3","17","CP95");

		getData("电流有效值","1","21","最大值");
		getData("电流有效值","2","21","最小值");
		getData("电流有效值","0","21","平均值");
		getData("电流有效值","3","21","CP95");

//		getData("电流总谐波畸变率","1","22","最大值");
//		getData("电流总谐波畸变率","2","22","最小值");
//		getData("电流总谐波畸变率","0","22","平均值");
//		getData("电流总谐波畸变率","3","22","CP95");

//		getData("频率","1","31","最大值");
//		getData("频率","2","31","最小值");
//		getData("频率","0","31","平均值");
//		getData("频率","3","31","CP95");

//		getData("谐波电压含有率","1","41","最大值");
//		getData("谐波电压含有率","2","41","最小值");
//		getData("谐波电压含有率","0","41","平均值");
//		getData("谐波电压含有率","3","41","CP95");

//		getData("谐波电流幅值","1","42","最大值");
//		getData("谐波电流幅值","2","42","最小值");
//		getData("谐波电流幅值","0","42","平均值");
//		getData("谐波电流幅值","3","42","CP95");

		getData("三相有功总功率","1","54","最大值");
		getData("三相有功总功率","2","54","最小值");
		getData("三相有功总功率","0","54","平均值");
		getData("三相有功总功率","3","54","CP95");

		getData("三相无功总功率","1","55","最大值");
		getData("三相无功总功率","2","55","最小值");
		getData("三相无功总功率","0","55","平均值");
		getData("三相无功总功率","3","55","CP95");

//		getData("三相视在总功率","1","56","最大值");
//		getData("三相视在总功率","2","56","最小值");
//		getData("三相视在总功率","0","56","平均值");
//		getData("三相视在总功率","3","56","CP95");

//		getData("短时电压闪变","0","61","平均值");
//
//		getData("长时电压闪变","0","62","平均值");
//
//		getData("基波电压","0","41","","1");
//
//		getData("基波电流","0","42","","1");

		getData("1次谐波电压","0","41","","1");
		getData("2次谐波电压","0","41","","2");
		getData("3次谐波电压","0","41","","3");
		getData("4次谐波电压","0","41","","4");
		getData("5次谐波电压","0","41","","5");
		getData("6次谐波电压","0","41","","6");
		getData("7次谐波电压","0","41","","7");
		getData("8次谐波电压","0","41","","8");
		getData("9次谐波电压","0","41","","9");
		getData("10次谐波电压","0","41","","10");
		getData("11次谐波电压","0","41","","11");
		getData("12次谐波电压","0","41","","12");
		getData("13次谐波电压","0","41","","13");
		getData("14次谐波电压","0","41","","14");
		getData("15次谐波电压","0","41","","15");
		getData("16次谐波电压","0","41","","16");
		getData("17次谐波电压","0","41","","17");
		getData("18次谐波电压","0","41","","18");
		getData("19次谐波电压","0","41","","19");
		getData("20次谐波电压","0","41","","20");
		getData("21次谐波电压","0","41","","21");
		getData("22次谐波电压","0","41","","22");
		getData("23次谐波电压","0","41","","23");
		getData("24次谐波电压","0","41","","24");
		getData("25次谐波电压","0","41","","25");

		getData("1次谐波电流","0","42","","1");
		getData("2次谐波电流","0","42","","2");
		getData("3次谐波电流","0","42","","3");
		getData("4次谐波电流","0","42","","4");
		getData("5次谐波电流","0","42","","5");
		getData("6次谐波电流","0","42","","6");
		getData("7次谐波电流","0","42","","7");
		getData("8次谐波电流","0","42","","8");
		getData("9次谐波电流","0","42","","9");
		getData("10次谐波电流","0","42","","10");
		getData("11次谐波电流","0","42","","11");
		getData("12次谐波电流","0","42","","12");
		getData("13次谐波电流","0","42","","13");
		getData("14次谐波电流","0","42","","14");
		getData("15次谐波电流","0","42","","15");
		getData("16次谐波电流","0","42","","16");
		getData("17次谐波电流","0","42","","17");
		getData("18次谐波电流","0","42","","18");
		getData("19次谐波电流","0","42","","19");
		getData("20次谐波电流","0","42","","20");
		getData("21次谐波电流","0","42","","21");
		getData("22次谐波电流","0","42","","22");
		getData("23次谐波电流","0","42","","23");
		getData("24次谐波电流","0","42","","24");
		getData("25次谐波电流","0","42","","25");

		getXbDy();

		getXbDl();

		var lineIndex = window.parent.document.getElementById("lineIndex").value;
		var name = window.parent.document.getElementById("lineName").value;
		var filename = $("#template").find("option:selected").text();
		var startTime = $("#startTime").val();
		var endTime = $("#endTime").val();

		$.ajax({
			method : "post",
			url : "/pqs9000/devicereport/saveReport",
			data : {
				lineIndex:lineIndex,
				name:name,
				filename:filename,
				startTime:startTime,
				endTime:endTime
			},
			dataType : 'text',
			success : function(data) {
				if (data == "pathfail") {
					layer.msg("生成失败,模板路径错误!", {
						icon : 5,
						time : 2000
					});
						//***********关闭loading
						ityzl_CLOSE_LOAD_LAYER(idea);
				} else if (data == "filefail") {
					layer.msg("生成失败,上传图片文件有误!", {
						icon : 5,
						time : 2000
					});
					//***********关闭loading
					ityzl_CLOSE_LOAD_LAYER(idea);
				} else if (data == "exportworld") {
					layer.msg("生成失败,数据有误!", {
						icon : 5,
						time : 2000
					});
					//***********关闭loading
					ityzl_CLOSE_LOAD_LAYER(idea);
				} else {
					layer.msg("生成成功!", {
						icon : 1,
						time : 2000
					}, function() {
						self.location.href = "/pqs9000/devicereport/downloadModel";
						loadReport();
						//***********关闭loading
						ityzl_CLOSE_LOAD_LAYER(idea);
					});
				}
			}
		})
	})
})

$('#nodelist').on("click", ".btn_exp", function() {
		objTable=$('#nodelist').DataTable();
		if (objTable != null) {
			var item = objTable.row($(this).closest('tr')).data();
			var reportIndex = item[0];
			var reportName = item[1];
			layer.confirm('是否确认？',function(){
				$.ajax({
					method : "post",
					url : "/pqs9000/devicereport/delReportInfo",
					data : {
						reportIndex:reportIndex,
						reportName:reportName
					},
					success : function(data) {
						if(data.code==200){
							layer.msg('删除成功!',{icon:1,time:1000});
							loadReport();
						}else{
							layer.msg('删除失败！',{icon:2,time:1000});
						}
					}
				})
			})
		}
	});

$('#nodelist').on("click", ".btn_dow", function() {
	objTable=$('#nodelist').DataTable();
	if (objTable != null) {
		var item = objTable.row($(this).closest('tr')).data();
		var reportName = item[1];
			$.ajax({
				method : "post",
				url : "/pqs9000/devicereport/checkReport",
				data : {
					reportName:reportName
				},
				success : function(data) {
					if(data.code==200){
						self.location.href = "/pqs9000/devicereport/downReport";
					}else{
						layer.msg(data.message,{icon:2,time:1000});
					}
				}
			})
	}
});

$('#nodelist').on("click", ".btn_dowup", function() {
	objTable=$('#nodelist').DataTable();
	if (objTable != null) {
		var item = objTable.row($(this).closest('tr')).data();
		var reportName = item[1];
			$.ajax({
				method : "post",
				url : "/pqs9000/devicereport/checkUpReport",
				data : {
					reportName:reportName
				},
				success : function(data) {
					if(data.code==200){
						self.location.href = "/pqs9000/devicereport/downUpReport";
					}else{
						layer.msg(data.message,{icon:2,time:1000});
					}
				}
			})
	}
});

$('#nodelist').on("click", ".btn_mod", function() {
	objTable=$('#nodelist').DataTable();
	if (objTable != null) {
		var item = objTable.row($(this).closest('tr')).data();
		var reportIndex = item[0];
		var reportName = item[1];
		layer.open({
			  type: 2,
			  title: '更新报告',
			  shadeClose: true,
	          offset: '0px',
			  area: ['300px', '160px'],
			  maxmin : false,
			  content: 'upoffreport?reportIndex='+reportIndex+'&reportName='+reportName,
			  scrollbar: false,
			  end:function(){
				  loadReport();
			  }
			});
	}
});

$("#ploymanage").click(function(){
		layer.open({
		  type: 2,
		  title: '模板管理',
		  shadeClose: true,
		  area : ['100%' , '100%'],
          offset: '0px',
		  maxmin : false,
		  content: 'ploymanage',
		  scrollbar: false,
		  end:function(){
			  $("#template").empty();
			  loadPloy();
		  }
		});
	});

var obj_Search;
var pointmsg = 1;// 监测点个数
var xhcs = 0;// 分割查询次数，默认是0次表示不需要进行查询
var realxhcs = 0;// 实际需要循环次数

function getData(condition,valueType,nodes,Typename,harmonic) {
	var aoData = new Array();
	obj_Search = new Object();
	obj_Search.valueType = valueType;
	obj_Search.point = window.parent.document.getElementById("lineIndex").value;
	obj_Search.historynum = 1;
	var startTime = $("#startTime").val();// 起始时间
	var endTime = $("#endTime").val();// 结束时间
	if(harmonic!=null || harmonic!=""){
		obj_Search.harmonic = harmonic;
	}

	obj_Search.startAllTime = timestampToDAY(new Date(startTime));// 总起始时间
	obj_Search.endAllTime = timestampToDAY(new Date(endTime));// 总结束时间
	obj_Search.startTime = timestampToDAY(new Date(startTime));
	obj_Search.endTime = timestampToDAY(new Date(endTime));
	obj_Search.start = timestampToSECOND(new Date(startTime));
	obj_Search.end = timestampToSECOND(new Date(endTime));
	obj_Search.condition = nodes;
	obj_Search.dataType = 0 //0,默认 在线 1，离线
	aoData.push(obj_Search);
	getZj(aoData);
	var name = window.parent.document.getElementById("lineName").value;
	$.ajax({
		type : 'POST',
		url : '/pqs9000/device/getHistoryResult',
		data : {
			obj : JSON.stringify(aoData)
		},
		error : function(data) {
			layer.msg("未获取到历史数据", {
				icon : 5,
				time : 3000
			});
		},
		success : function(data) {
			InstantiationParameter();
			aoData.historynum = parseInt(data.msg);
			analysisData(data, data.msg2);// 数据解析
			drawCharts(condition,Typename);
		}
	})
}

function drawCharts(targetName,Typename) {
	var objdata = [];
	$('#container1').html("");
	if (obj_History.length > 0) {
		var name = window.parent.document.getElementById("lineName").value;
		var targetName;// 所选择指标名称
		objdata = splitObj_History[0];
		initWave(name, targetName, objdata,Typename);
	}
}


function InstantiationParameter() {
	// 参数初始化
	Obj_Limit = [];
	obj_History = [];
	splitObj_History = [];
	yevent_value = [];// 最小值
	events = [];// 所有暂降事件汇总
	series_Data = [];// 展示数据
	series_Nav = [];// 导航栏
	colo = [];// 颜色
	titleName = null;// 图形标题名称
	objdata = [];
}

function analysisData(data, msg2) {
	var tmpData;// 根据图
	// 数据解析
	for (var m = 0; m < obj_Search.historynum; m++) {
		// 定义obj存储数据
		var tmpObj_Data = [];
		// 数据源获取定义
		switch (m) {
		case 0:
			tmpData = data.data1;
			break;
		case 1:
			tmpData = data.data2;
			break;
		case 2:
			tmpData = data.data3;
			break;
		}
		// 开始解析数据

		var amax = [], bmax = [], cmax = [], amin = [], bmin = [], cmin = [], acp95 = [], bcp95 = [], ccp95 = [], avr = [], bvr = [], cvr = [], flicker = [], SfreqDev = [], XfreqDev = [], uaberrance = [], ubalance = [], SvoltageDev = [], XvoltageDev = [], iharm = [], uharm = [], fmax = [], fvr = [], fmin = [], fcp95 = [], zjamin = [], zjbmin = [], zjcmin = [], zjfmin = [];
		var tmpTime;// 获取时间
		var tmpObj_Limit = null;
		tmpObj_Limit = Obj_Limit[0];

		if (tmpData.length > 0) {
			if (tmpData[0][0] == 15 || tmpData[0][0] == 31 || tmpData[0][0] == 54 || tmpData[0][0] == 55 || tmpData[0][0] == 56) {
				for (var i = 0; i < tmpData.length; i++) {
					tmpTime = parseFloat(tmpData[i][1]);
					// 平均值
					fvr.push([ tmpTime, parseFloat(tmpData[i][2]) ]);
					// 最大值
					fmax.push([ tmpTime, parseFloat(tmpData[i][3]) ]);
					// 最小值
					fmin.push([ tmpTime, parseFloat(tmpData[i][4]) ]);
					// cp95
					fcp95.push([ tmpTime, parseFloat(tmpData[i][5]) ]);
					// 计算暂降触发点最小值,采用最小值abc三项进行对比
					zjfmin.push(parseFloat(tmpData[i][6]));
					// 获取限值
					if (tmpObj_Limit != null) {
						flicker.push([ tmpTime, tmpObj_Limit.flicker ]);
						SfreqDev.push([ tmpTime, tmpObj_Limit.SfreqDev ]);
						XfreqDev.push([ tmpTime, tmpObj_Limit.XfreqDev ]);
						uaberrance.push([ tmpTime, tmpObj_Limit.uaberrance ]);
						ubalance.push([ tmpTime, tmpObj_Limit.ubalance ]);
						SvoltageDev.push([ tmpTime, tmpObj_Limit.SvoltageDev ]);
						XvoltageDev.push([ tmpTime, tmpObj_Limit.XvoltageDev ]);
						if (parseInt(obj_Search.harmonic) > 1
								&& parseInt(obj_Search.harmonic) < 26) {
							uharm
									.push([
											tmpTime,
											tmpObj_Limit.uharm[parseInt(obj_Search.harmonic)] ]);
							iharm
									.push([
											tmpTime,
											tmpObj_Limit.iharm[parseInt(obj_Search.harmonic)] ]);
						}
					}
				}
				// 获取暂降触发点信息
				tmpData = obj_ZjCf;
				var zjzmin = [];
				zjzmin.push(Math.min.apply(Math, zjamin));
				zjzmin.push(Math.min.apply(Math, zjbmin));
				zjzmin.push(Math.min.apply(Math, zjcmin));
				yevent_value = Math.min.apply(Math, zjzmin);
				// 监测点个数
				var obj_Event = new Object();
				var eIndex = [], eTime = [];
				events = [];
				if (tmpData[0][0] != null) {
					for (var i = 0; i < tmpData[0][0].length; i++) {
						eIndex.push(tmpData[0][0][i][0]);
						eTime.push([ parseFloat(tmpData[0][0][i][1]),
								yevent_value ])
					}
					tmpObj_Data[21] = eIndex;
					tmpObj_Data[22] = eTime;
					tmpObj_Data[23] = pointmsg;
				} else {
					tmpObj_Data[21] = eIndex;
					tmpObj_Data[22] = eTime;
					tmpObj_Data[23] = pointmsg;
				}
				// 临时数据赋值
				tmpObj_Data[0] = fvr;
				tmpObj_Data[1] = fmax;
				tmpObj_Data[2] = fmin;
				tmpObj_Data[3] = fcp95;
				// 限值
				tmpObj_Data[12] = XfreqDev;// 频率下偏差
				tmpObj_Data[13] = SfreqDev;// 频率上偏差
				tmpObj_Data[14] = uaberrance;// 电压总谐波畸变率
				tmpObj_Data[15] = ubalance;// 三相电压不平衡度
				tmpObj_Data[16] = XvoltageDev;// 电压下偏差
				tmpObj_Data[17] = SvoltageDev;// 电压上偏差
				tmpObj_Data[18] = flicker;// 闪变
				tmpObj_Data[19] = uharm;
				tmpObj_Data[20] = iharm;
				splitObj_History[m] = (tmpObj_Data);
				// 把每次查询到的整体数据赋值给全局变量（给切换时候用）
				var tmpObj_History = splitObj_History[m];
				// 假如不为空则执行更新
				if (tmpObj_History != null) {
					// 临时数据赋值
					tmpObj_History[0] = tmpObj_History[0].concat(fvr);
					tmpObj_History[1] = tmpObj_History[1].concat(fmax);
					tmpObj_History[2] = tmpObj_History[2].concat(fmin);
					tmpObj_History[2] = tmpObj_History[3].concat(fcp95);
					tmpObj_History[12] = tmpObj_History[12].concat(XfreqDev);
					tmpObj_History[13] = tmpObj_History[13].concat(SfreqDev);
					tmpObj_History[14] = tmpObj_History[14].concat(uaberrance);
					tmpObj_History[15] = tmpObj_History[15].concat(ubalance);
					tmpObj_History[16] = tmpObj_History[16].concat(XvoltageDev);
					tmpObj_History[17] = tmpObj_History[17].concat(SvoltageDev);
					tmpObj_History[18] = tmpObj_History[18].concat(flicker);
					tmpObj_History[19] = tmpObj_History[19].concat(uharm);
					tmpObj_History[20] = tmpObj_History[20].concat(iharm);
					obj_History[m] = tmpObj_History;// 重新给该位置赋值
				}
				// 假如为空则执行插入
				else {
					obj_History.push(tmpObj_Data);
				}
			} else {
				// 数据解析
				for (var i = 0; i < tmpData.length; i++) {

					if (tmpData[0][0] == 61 || tmpData[0][0] == 62
							|| tmpData[0][0] == 63) {
						tmpTime = parseFloat(tmpData[i][1]);
						// 平均值
						avr.push([ tmpTime, parseFloat(tmpData[i][2]) ]);
						bvr.push([ tmpTime, parseFloat(tmpData[i][3]) ]);
						cvr.push([ tmpTime, parseFloat(tmpData[i][4]) ]);
						// 计算暂降触发点最小值,采用最小值abc三项进行对比
						zjamin.push(parseFloat(tmpData[i][2]));
						zjbmin.push(parseFloat(tmpData[i][3]));
						zjcmin.push(parseFloat(tmpData[i][4]));
						// 获取限值
						if (tmpObj_Limit != null) {
							flicker.push([ tmpTime, tmpObj_Limit.flicker ]);
							SfreqDev.push([ tmpTime, tmpObj_Limit.SfreqDev ]);
							XfreqDev.push([ tmpTime, tmpObj_Limit.XfreqDev ]);
							uaberrance
									.push([ tmpTime, tmpObj_Limit.uaberrance ]);
							ubalance.push([ tmpTime, tmpObj_Limit.ubalance ]);
							SvoltageDev.push([ tmpTime,
									tmpObj_Limit.SvoltageDev ]);
							XvoltageDev.push([ tmpTime,
									tmpObj_Limit.XvoltageDev ]);
							if (parseInt(harmonic) > 1
									&& parseInt(harmonic) < 26) {
								uharm
										.push([
												tmpTime,
												tmpObj_Limit.uharm[parseInt(harmonic) - 2] ]);
								iharm
										.push([
												tmpTime,
												tmpObj_Limit.iharm[parseInt(harmonic) - 2] ]);
							}
						}
					} else {
						tmpTime = parseFloat(tmpData[i][1]);
						// 平均值
						avr.push([ tmpTime, parseFloat(tmpData[i][2]) ]);
						bvr.push([ tmpTime, parseFloat(tmpData[i][3]) ]);
						cvr.push([ tmpTime, parseFloat(tmpData[i][4]) ]);
						// 最小值
						amin.push([ tmpTime, parseFloat(tmpData[i][5]) ]);
						bmin.push([ tmpTime, parseFloat(tmpData[i][6]) ]);
						cmin.push([ tmpTime, parseFloat(tmpData[i][7]) ]);

						// 计算暂降触发点最小值,采用最小值abc三项进行对比
						zjamin.push(parseFloat(tmpData[i][5]));
						zjbmin.push(parseFloat(tmpData[i][6]));
						zjcmin.push(parseFloat(tmpData[i][7]));
						// 最大值
						amax.push([ tmpTime, parseFloat(tmpData[i][8]) ]);
						bmax.push([ tmpTime, parseFloat(tmpData[i][9]) ]);
						cmax.push([ tmpTime, parseFloat(tmpData[i][10]) ]);
						// CP95值
						acp95.push([ tmpTime, parseFloat(tmpData[i][11]) ]);
						bcp95.push([ tmpTime, parseFloat(tmpData[i][12]) ]);
						ccp95.push([ tmpTime, parseFloat(tmpData[i][13]) ]);
						// 获取限值
						if (tmpObj_Limit != null) {
							flicker.push([ tmpTime, tmpObj_Limit.flicker ]);
							SfreqDev.push([ tmpTime, tmpObj_Limit.SfreqDev ]);
							XfreqDev.push([ tmpTime, tmpObj_Limit.XfreqDev ]);
							uaberrance
									.push([ tmpTime, tmpObj_Limit.uaberrance ]);
							ubalance.push([ tmpTime, tmpObj_Limit.ubalance ]);
							SvoltageDev.push([ tmpTime,
									tmpObj_Limit.SvoltageDev ]);
							XvoltageDev.push([ tmpTime,
									tmpObj_Limit.XvoltageDev ]);
							if (parseInt(harmonic) > 1
									&& parseInt(harmonic) < 26) {
								uharm
										.push([
												tmpTime,
												tmpObj_Limit.uharm[parseInt(harmonic) - 2] ]);
								iharm
										.push([
												tmpTime,
												tmpObj_Limit.iharm[parseInt(harmonic) - 2] ]);
							}
						}
					}
				}
				// 获取暂降触发点信息
				tmpData = obj_ZjCf;
				var zjzmin = [];
				zjzmin.push(Math.min.apply(Math, zjamin));
				zjzmin.push(Math.min.apply(Math, zjbmin));
				zjzmin.push(Math.min.apply(Math, zjcmin));
				yevent_value = Math.min.apply(Math, zjzmin);
				// 监测点个数
				var obj_Event = new Object();
				var eIndex = [], eTime = [];
				events = [];
				if (tmpData[0][0] != null) {
					for (var i = 0; i < tmpData[0][0].length; i++) {
						eIndex.push(tmpData[0][0][i][0]);
						eTime.push([ parseFloat(tmpData[0][0][i][1]),
								yevent_value ])
					}
					tmpObj_Data[21] = eIndex;
					tmpObj_Data[22] = eTime;
					tmpObj_Data[23] = pointmsg;
				} else {
					tmpObj_Data[21] = eIndex;
					tmpObj_Data[22] = eTime;
					tmpObj_Data[23] = pointmsg;
				}

				// 临时数据赋值
				tmpObj_Data[0] = avr;
				tmpObj_Data[1] = amax;
				tmpObj_Data[2] = amin;
				tmpObj_Data[3] = acp95;
				tmpObj_Data[4] = bvr;
				tmpObj_Data[5] = bmax;
				tmpObj_Data[6] = bmin;
				tmpObj_Data[7] = bcp95;
				tmpObj_Data[8] = cvr;
				tmpObj_Data[9] = cmax;
				tmpObj_Data[10] = cmin;
				tmpObj_Data[11] = ccp95;
				// 限值
				tmpObj_Data[12] = XfreqDev;// 频率下偏差
				tmpObj_Data[13] = SfreqDev;// 频率上偏差
				tmpObj_Data[14] = uaberrance;// 电压总谐波畸变率
				tmpObj_Data[15] = ubalance;// 三相电压不平衡度
				tmpObj_Data[16] = XvoltageDev;// 电压下偏差
				tmpObj_Data[17] = SvoltageDev;// 电压上偏差
				tmpObj_Data[18] = flicker;// 闪变
				tmpObj_Data[19] = uharm;
				tmpObj_Data[20] = iharm;
				splitObj_History[m] = (tmpObj_Data);
				// 把每次查询到的整体数据赋值给全局变量（给切换时候用）
				var tmpObj_History = obj_History[m];
				// 假如不为空则执行更新
				if (tmpObj_History != null) {
					// 临时数据赋值
					tmpObj_History[0] = tmpObj_History[0].concat(avr);
					tmpObj_History[1] = tmpObj_History[1].concat(amax);
					tmpObj_History[2] = tmpObj_History[2].concat(amin);
					tmpObj_History[3] = tmpObj_History[3].concat(acp95);
					tmpObj_History[4] = tmpObj_History[4].concat(bvr);
					tmpObj_History[5] = tmpObj_History[5].concat(bmax);
					tmpObj_History[6] = tmpObj_History[6].concat(bmin);
					tmpObj_History[7] = tmpObj_History[7].concat(bcp95);
					tmpObj_History[8] = tmpObj_History[8].concat(cvr);
					tmpObj_History[9] = tmpObj_History[9].concat(cmax);
					tmpObj_History[10] = tmpObj_History[10].concat(cmin);
					tmpObj_History[11] = tmpObj_History[11].concat(ccp95);
					tmpObj_History[12] = tmpObj_History[12].concat(XfreqDev);
					tmpObj_History[13] = tmpObj_History[13].concat(SfreqDev);
					tmpObj_History[14] = tmpObj_History[14].concat(uaberrance);
					tmpObj_History[15] = tmpObj_History[15].concat(ubalance);
					tmpObj_History[16] = tmpObj_History[16].concat(XvoltageDev);
					tmpObj_History[17] = tmpObj_History[17].concat(SvoltageDev);
					tmpObj_History[18] = tmpObj_History[18].concat(flicker);
					tmpObj_History[19] = tmpObj_History[19].concat(uharm);
					tmpObj_History[20] = tmpObj_History[20].concat(iharm);
					obj_History[m] = tmpObj_History;// 重新给该位置赋值
				}
				// 假如为空则执行插入
				else {
					obj_History.push(tmpObj_Data);
				}
			}
		}
	}
}

function pushWaveData(targetName, data, number) {
	colo = [];
	titleName = null;// 图形标题名称
	var tmpSeries_Data = [];// 展示数据
	var tmpSeries_Nav = [];// 导航栏
	var subdata = parseInt(obj_Search.valueType);// 取值下标
	if (data == null) {
		if (series_Data.length < 3) {
			series_Data.push(tmpSeries_Data);
			series_Nav.push(tmpSeries_Nav);
		}
	} else {
		if (targetName == "频率" || targetName == "三相电压不平衡度") {
			if (targetName == "三相不平衡度") {
				tmpSeries_Nav.push({
					"data" : data[subdata]
				});
				tmpSeries_Data.push({
					"name" : "三相不平衡度",
					"data" : data[subdata]
				});
				tmpSeries_Data.push({
					"dashStyle" : "shortdash",
					"name" : "上限",
					"data" : data[15]
				});
				colo.push(yellow, red)
			} else {
				tmpSeries_Nav.push({
					"data" : data[subdata]
				});
				tmpSeries_Data.push({
					"name" : "频率",
					"data" : data[subdata]
				});
				tmpSeries_Data.push({
					"dashStyle" : "shortdash",
					"name" : "上限",
					"data" : data[13]
				});
				tmpSeries_Data.push({
					"dashStyle" : "shortdash",
					"name" : "下限",
					"data" : data[12]
				});
				colo.push(yellow, red, red)
			}
		} else if (targetName == "电压总谐波畸变率") {
			tmpSeries_Nav.push({
				"data" : data[subdata + 0]
			});
			tmpSeries_Nav.push({
				"data" : data[subdata + 4]
			});
			tmpSeries_Nav.push({
				"data" : data[subdata + 8]
			});
			tmpSeries_Data.push({
				"name" : "A相",
				"data" : data[subdata]
			});
			tmpSeries_Data.push({
				"name" : "B相",
				"data" : data[subdata + 4]
			});
			tmpSeries_Data.push({
				"name" : "C相",
				"data" : data[subdata + 8]
			});
			tmpSeries_Data.push({
				"dashStyle" : "shortdash",
				"name" : "上限",
				"data" : data[14]
			});
			colo.push(yellow, green, red, red);
		} else if (targetName == "电压偏差") {
			titleName = null;
			tmpSeries_Nav.push({
				"data" : data[subdata + 0]
			});
			tmpSeries_Nav.push({
				"data" : data[subdata + 4]
			});
			tmpSeries_Nav.push({
				"data" : data[subdata + 8]
			});
			tmpSeries_Data.push({
				"name" : "A相",
				"data" : data[subdata + 0]
			});
			tmpSeries_Data.push({
				"name" : "B相",
				"data" : data[subdata + 4]
			});
			tmpSeries_Data.push({
				"name" : "C相",
				"data" : data[subdata + 8]
			});
			tmpSeries_Data.push({
				"dashStyle" : "shortdash",
				"name" : "上限",
				"data" : data[17]
			});
			tmpSeries_Data.push({
				"dashStyle" : "shortdash",
				"name" : "下限",
				"data" : data[16]
			});
			colo.push(yellow, green, red, red, red);
		} else if (targetName == "长时电压闪变") {
			titleName = "该指标只有平均值";
			tmpSeries_Nav.push({
				"data" : data[subdata + 0],
				"step": 'middle'
			});
			tmpSeries_Nav.push({
				"data" : data[subdata + 4],
				"step": 'middle'
			});
			tmpSeries_Nav.push({
				"data" : data[subdata + 8],
				"step": 'middle'
			});
			tmpSeries_Data.push({
				"name" : "A相",
				"data" : data[subdata + 0],
				"step": 'middle'
			});
			tmpSeries_Data.push({
				"name" : "B相",
				"data" : data[subdata + 4],
				"step": 'middle'
			});
			tmpSeries_Data.push({
				"name" : "C相",
				"data" : data[subdata + 8],
				"step": 'middle'
			});
			tmpSeries_Data.push({
				"dashStyle" : "shortdash",
				"name" : "上限",
				"data" : data[18]
			});
			colo.push(yellow, green, red, red);
		} else if (targetName == "短时电压闪变" || targetName == "电压波动") {
			titleName = "该指标只有平均值";
			tmpSeries_Nav.push({
				"data" : data[subdata + 0],
				"step": 'middle'
			});
			tmpSeries_Nav.push({
				"data" : data[subdata + 4],
				"step": 'middle'
			});
			tmpSeries_Nav.push({
				"data" : data[subdata + 8],
				"step": 'middle'
			});
			tmpSeries_Data.push({
				"name" : "A相",
				"data" : data[subdata + 0],
				"step": 'middle'
			});
			tmpSeries_Data.push({
				"name" : "B相",
				"data" : data[subdata + 4],
				"step": 'middle'
			});
			tmpSeries_Data.push({
				"name" : "C相",
				"data" : data[subdata + 8],
				"step": 'middle'
			});
			colo.push(yellow, green, red);
		} else if (targetName == "线电压有效值") {
			tmpSeries_Nav.push({
				"data" : data[subdata + 0]
			});
			tmpSeries_Nav.push({
				"data" : data[subdata + 4]
			});
			tmpSeries_Nav.push({
				"data" : data[subdata + 8]
			});
			tmpSeries_Data.push({
				"name" : "AB相",
				"data" : data[subdata + 0]
			});
			tmpSeries_Data.push({
				"name" : "BC相",
				"data" : data[subdata + 4]
			});
			tmpSeries_Data.push({
				"name" : "CA相",
				"data" : data[subdata + 8]
			});
			colo.push(yellow, green, red);
		} else if (targetName == "电压不平衡度") {
			tmpSeries_Nav.push({
				"data" : data[subdata + 0]
			});
			tmpSeries_Nav.push({
				"data" : data[subdata + 4]
			});
			tmpSeries_Nav.push({
				"data" : data[subdata + 8]
			});
			tmpSeries_Data.push({
				"name" : "零序电压(V)",
				"data" : data[subdata + 0]
			});
			tmpSeries_Data.push({
				"name" : "正序电压(kV)",
				"data" : data[subdata + 4]
			});
			tmpSeries_Data.push({
				"name" : "负序电压(V)",
				"data" : data[subdata + 8]
			});
			colo.push(yellow, green, red);
		} else if (targetName == "谐波电压含有率") {
			if (parseInt(obj_Search.harmonic) > 1
					&& parseInt(obj_Search.harmonic) < 26) {
				tmpSeries_Nav.push({
					"data" : data[subdata + 0]
				});
				tmpSeries_Nav.push({
					"data" : data[subdata + 4]
				});
				tmpSeries_Nav.push({
					"data" : data[subdata + 8]
				});
				tmpSeries_Data.push({
					"name" : "A相",
					"data" : data[subdata + 0]
				});
				tmpSeries_Data.push({
					"name" : "B相",
					"data" : data[subdata + 4]
				});
				tmpSeries_Data.push({
					"name" : "C相",
					"data" : data[subdata + 8]
				});
				tmpSeries_Data.push({
					"dashStyle" : "shortdash",
					"name" : parseInt(obj_Search.harmonic) + "次上限",
					"data" : data[19]
				});
				colo.push(yellow, green, red, red);
			} else {
				tmpSeries_Nav.push({
					"data" : data[subdata + 0]
				});
				tmpSeries_Nav.push({
					"data" : data[subdata + 4]
				});
				tmpSeries_Nav.push({
					"data" : data[subdata + 8]
				});
				tmpSeries_Data.push({
					"name" : "A相",
					"data" : data[subdata + 0]
				});
				tmpSeries_Data.push({
					"name" : "B相",
					"data" : data[subdata + 4]
				});
				tmpSeries_Data.push({
					"name" : "C相",
					"data" : data[subdata + 8]
				});
				colo.push(yellow, green, red);
			}
		} else if (targetName == "谐波电流幅值") {
			if (parseInt(obj_Search.harmonic) > 1
					&& parseInt(obj_Search.harmonic) < 26) {
				tmpSeries_Nav.push({
					"data" : data[subdata + 0]
				});
				tmpSeries_Nav.push({
					"data" : data[subdata + 4]
				});
				tmpSeries_Nav.push({
					"data" : data[subdata + 8]
				});
				tmpSeries_Data.push({
					"name" : "A相",
					"data" : data[subdata + 0]
				});
				tmpSeries_Data.push({
					"name" : "B相",
					"data" : data[subdata + 4]
				});
				tmpSeries_Data.push({
					"name" : "C相",
					"data" : data[subdata + 8]
				});
				tmpSeries_Data.push({
					"dashStyle" : "shortdash",
					"name" : parseInt(obj_Search.harmonic) + "次上限",
					"data" : data[20]
				});
				colo.push(yellow, green, red, red);
			} else {
				tmpSeries_Nav.push({
					"data" : data[subdata + 0]
				});
				tmpSeries_Nav.push({
					"data" : data[subdata + 4]
				});
				tmpSeries_Nav.push({
					"data" : data[subdata + 8]
				});
				tmpSeries_Data.push({
					"name" : "A相",
					"data" : data[subdata + 0]
				});
				tmpSeries_Data.push({
					"name" : "B相",
					"data" : data[subdata + 4]
				});
				tmpSeries_Data.push({
					"name" : "C相",
					"data" : data[subdata + 8]
				});
				colo.push(yellow, green, red);
			}
		} else if (targetName == "三相有功总功率" || targetName == "三相无功总功率" || targetName == "三相视在总功率") {
            tmpSeries_Nav.push({
                "data": data[subdata + 0]
            });
            tmpSeries_Data.push({
                "name": "总功功率",
                "data": data[subdata + 0]
            });
            colo.push(black);
        } else {
			tmpSeries_Nav.push({
				"data" : data[subdata + 0]
			});
			tmpSeries_Nav.push({
				"data" : data[subdata + 4]
			});
			tmpSeries_Nav.push({
				"data" : data[subdata + 8]
			});
			tmpSeries_Data.push({
				"name" : "A相",
				"data" : data[subdata + 0]
			});
			tmpSeries_Data.push({
				"name" : "B相",
				"data" : data[subdata + 4]
			});
			tmpSeries_Data.push({
				"name" : "C相",
				"data" : data[subdata + 8]
			});
			colo.push(yellow, green, red);
		}
		// 判断监测点的个数
		if (data[23] == 1) {// 一个监测点
			if ((number + 1) == 1) {
			}
		} else if (data[23] == 2) {// 二个监测点
			if ((number + 1) == 1) {

			} else if (number + 1 == 2) {

			}
		} else if (data[23] == 3) {// 三个监测点
			if ((number + 1) == 1) {

			} else if (number + 1 == 2) {

			} else {

			}
		}
		series_Data.push(tmpSeries_Data);
		series_Nav.push(tmpSeries_Nav);

	}

}

function initWave(name, targetName, data,Typename) {
	var index1 = [];
	var zj = [], getZj = [], zmin = [];
	var unit = getUnit(targetName);// 获取展示Y单位
	pushWaveData(targetName, data, 0);// 根据target给图形幅值
	if (targetName == "谐波电压含有率") {
		if (parseInt(obj_Search.harmonic) == 1) {
			targetName = "基波电压";
			unit = "kV";
		} else {
			targetName = parseInt(obj_Search.harmonic) + "次谐波电压含有率";
		}
	} else if (targetName == "谐波电流幅值") {
		if (parseInt(obj_Search.harmonic) == 1) {
			targetName = "基波电流";
			unit = "A";
		} else {
			targetName = parseInt(obj_Search.harmonic) + "次谐波电流幅值";
		}
	}
	Highcharts.setOptions({
		global : {
			useUTC : false
		}
	});
	var charData = Highcharts.stockChart('container1', {
		title : {
			text : name + " " + targetName + Typename
		},
		subtitle : {
			text : titleName,
			style : {
				color : "#ff0000"
			}
		},
//		chart : {
//			type : 'spline',
//		},
		dataLabels : {
			allowOverlap : true
		},
		tooltip : {
			borderColor : grey,
			backgroundColor : 'rgba(105,105,105,0.7)',
			style : {
				color : 'white',
				fontSize : "15px",
				padding : 10,
			},
			formatter : function() {
				var s = '<b>时刻：'
						+ Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x)
						+ '</b>';
				$.each(this.points, function() {
					if (this.series.name == "零序电压(V)") {
						s += '<br/>' + this.series.name + ': '
								+ this.y.toFixed(4) + 'V';
					} else if (this.series.name == "正序电压(kV)") {
						s += '<br/>' + this.series.name + ': '
								+ this.y.toFixed(4) + 'kV';
					} else if (this.series.name == "负序电压(V)") {
						s += '<br/>' + this.series.name + ': '
								+ this.y.toFixed(4) + 'V';
					} else {
						s += '<br/>' + this.series.name + ': '
								+ this.y.toFixed(4) + unit;
					}
				});
				return s;
			},
			shared : true
		},
		// 导航器各项属性设置
		navigator : {
			height : 20,
			margin : 1,
			xAxis : {
				labels : {
					formatter : function() {
						return Highcharts.dateFormat('%Y-%m-%d %H:%M:%S',
								this.value);
					}
				}
			},
			series : series_Nav[0]
		},
		rangeSelector : {
			enabled : false
		},
		scrollbar : {
			enabled : false
		},
		credits : false,
		colors : colo,
		xAxis : {
			title : {
				text : '(时间)',
				enabled : true,
				align : 'high',
			},
			labels : {
				step : 2
			},
			type : 'datetime',
			dateTimeLabelFormats : {
				second : '%H:%M:%S',
				minute : '%H:%M',
				hour : '%H:%M',
				day : '%m-%d',
				week : '%m-%d',
				month : '%Y-%m',
				year : '%Y'
			},
		},
		yAxis : {
			title : {
				align : 'high',
				offset : 0,
				text : unit,
				rotation : 0,
				y : -10
			},
			labels : {
				step : 1
			},
			tickPixelInterval: 10,
			opposite : false
		},
		legend : {
			align : 'left',
			verticalAlign : 'top',
			enabled : true
		},
		series : series_Data[0]
	});

	var charsvg=charData.getSVG();
	$.ajax({
		method : "post",
		url : "/pqs9000/devicereport/changesvg",
		data : {
			charData:charsvg,
			targetName:targetName,
			Typename:Typename
		},
		async:false,
		dataType : 'text',
		success : function(data) {
			$.ajax({
        		method : "post",
        		url : "/pqs9000/devicereport/readpng",
        		data : {},
        		async:false,
        		dataType : 'text',
        		success : function(data) {

        		}
        	});
		}
	});


}

/*******************************************************************************
 * 获取暂降触发点
 */
function getZj(aoData) {
	var result = true;
	$.ajax({
		type : 'POST',
		url : '/pqs9000/device/getZjCf',
		data : {
			obj : JSON.stringify(aoData)
		},
		error : function(data) {
			layer.msg("获取所选监测点限值失败，请联系管理员正确配置监测点信息！", {
				icon : 5,
				time : 3000
			});
			result = false;
		},
		success : function(data) {
			obj_ZjCf = [];
			// 数据返回集合长度
			obj_ZjCf.push(data);
		}
	})
}

/*******************************************************************************
 * 单位获取
 ******************************************************************************/
function getUnit(targetName) {
	var unit;
	if (targetName == "相电压有效值" || targetName == "线电压有效值") {
		unit = 'kV'; // 纵坐标单位为kV
	} else if (targetName == "三相不平衡度" || targetName == "电压偏差"
			|| targetName == "电压总谐波畸变率" || targetName == "电流总谐波畸变率"
			|| targetName == "谐波电压含有率" || targetName == "电压波动") {
		unit = '%'; // 纵坐标单位为%
	} else if (targetName == "电流有效值" || targetName == "谐波电流幅值") {
		unit = 'A'; // 纵坐标单位为A
	} else if (targetName == "频率") {
		unit = 'Hz'; // 纵坐标单位为Hz
	} else if (targetName == "短时电压闪变" || targetName == "长时电压闪变") {
		unit = ''; // 没有单位
	} else if (targetName == "三相有功总功率") {
		unit = 'kW'; // 单位为kW
	} else if (targetName == "三相无功总功率") {
		unit = 'kVar'; // 单位为kVar
	} else if (targetName == "三相视在总功率") {
		unit = 'kVA'; // 单位为kVA
	} else if (targetName == "电压不平衡度") {
		unit = '';
	}
	return unit;
}
var height=$(window).height()-180;
function getXbDy() {
	var type = '1';
	var targetName = "谐波电压频谱";
	var lineId = window.parent.document.getElementById("lineIndex").value;
    var startTime = $("#startTime").val();
    var endTime = $("#endTime").val();
    $.ajax({
        type : 'POST',
        url : '/pqs9000/device/getHarmonic',
        data : {
            startTime:startTime,
            endTime:endTime,
            lineId:lineId,
            type:type
        },
        success : function(data) {
            var serName=[];
            var gb=[];
            var number=[];
            //没有权限的请求
            if(data==300){
                //没有登陆的请求
            }else if(data==301){

            }else {
                if (data.code == 500) {
                    for(i=1;i<50;i++){
                        serName.push([parseFloat(null)]);
                        gb.push([parseFloat(null)]);
                        number.push([i+1])
                    }
                    $("#container1").css("height",height*0.6);
                    //画图
                    var chart = Highcharts.chart('container1', {
                        credits: {
                            enabled: false
                        },
                        chart: {
                            type: 'column'
                        },
                        title: {
                            text: ''
                        },
                        xAxis: {
                            categories: number
                        },
                        yAxis: [{
                            min: 0,
                            title: {
                                text: '谐波电压含有率(%)'
                            }
                        }, {
                            title: {
                                text: '国标限值(%)'
                            },
                            opposite: true
                        }],
                        legend: {
                            shadow: false
                        },
                        tooltip: {
                            shared: true,
                            formatter:function () {
                                var x,y1,y2;
                                if(this.points.length==1){
                                    x="谐波次数："+this.points[0].x
                                    y2=this.points[0].series.name+":"+this.points[0].y+"%"
                                    return x+'<br>'+y2;
                                }else{
                                    x="谐波次数："+this.points[0].x
                                    y1="国标限值(%):"+this.points[0].y+"%"
                                    y2="谐波电压含有率(%):"+this.points[1].y+"%"
                                    return x+'<br>'+y1+'<br>'+y2;
                                }


                            }
                        },
                        plotOptions: {
                            column: {
                                grouping: false,
                                shadow: false,
                                borderWidth: 0
                            }
                        },
                        series: [{
                            name: '谐波电压含有率(%)',
                            color: yellow,
                            data: gb,
                            tooltip: {
                                valueSuffix: '%'
                            },
                            pointPadding: 0.3,
                            pointPlacement: -0.2
                        }, {
                            name: '国标限值(%)',
                            color: green,
                            data: serName,
                            tooltip: {
                                valueSuffix: '%'
                            },
                            pointPadding: 0.4, // 通过 pointPadding 和 pointPlacement 控制柱子位置
                            pointPlacement: -0.2

                        }]
                    });

                    var chartsvg=chart.getSVG();
                	$.ajax({
                		method : "post",
                		url : "/pqs9000/devicereport/changesvg",
                		data : {
                			charData:chartsvg,
                			targetName:targetName,
                			Typename:""
                		},
                		async:false,
                		dataType : 'text',
                		success : function(data) {
                			$.ajax({
                        		method : "post",
                        		url : "/pqs9000/devicereport/readpng",
                        		data : {},
                        		async:false,
                        		dataType : 'text',
                        		success : function(data) {

                        		}
                        	});
                		}
                	});
                } else {
                    for(i=1;i<50;i++){
                        serName.push([parseFloat(data.body[0][i])]);
                        gb.push([parseFloat(data.body[1][i])]);
                        number.push([i+1])
                    }
                    $("#container1").css("height",height*0.8);
                    //画图
                    var chart = Highcharts.chart('container1', {
                        credits: {
                            enabled: false
                        },
                        chart: {
                            type: 'column'
                        },
                        title: {
                            text: ''
                        },
                        xAxis: {
                            categories: number,
                        },
                        yAxis: [{
                            min: 0,
                            title: {
                                text: data.body[0][0]
                            }
                        }, {
                            title: {
                                text: data.body[1][0]
                            },
                            opposite: true
                        }],
                        legend: {
                            shadow: false
                        },
                        tooltip: {
                            shared: true,
                            formatter:function () {
                                var x,y1,y2;
                                if(this.points.length==1){
                                    x="谐波次数："+this.points[0].x
                                    y2=this.points[0].series.name+":"+this.points[0].y+"%"
                                    return x+'<br>'+y2;
                                }else{
                                    x="谐波次数："+this.points[0].x
                                    y1="国标限值(%):"+this.points[0].y+"%"
                                    y2="谐波电压含有率(%):"+this.points[1].y+"%"
                                    return x+'<br>'+y1+'<br>'+y2;
                                }


                            }
                        },
                        plotOptions: {
                            column: {
                                grouping: false,
                                shadow: false,
                                borderWidth: 0
                            }
                        },
                        series: [{
                            name: data.body[1][0],
                            color: yellow,
                            data: gb,
                            tooltip: {
                                valueSuffix: '%'
                            },
                            pointPadding: 0.3,
                            pointPlacement: -0.2
                        }, {
                            name: data.body[0][0],
                            color: green,
                            data: serName,
                            tooltip: {
                                valueSuffix: '%'
                            },
                            pointPadding: 0.4, // 通过 pointPadding 和 pointPlacement 控制柱子位置
                            pointPlacement: -0.2

                        }]
                    });

                    var chartsvg=chart.getSVG();
                	$.ajax({
                		method : "post",
                		url : "/pqs9000/devicereport/changesvg",
                		data : {
                			charData:chartsvg,
                			targetName:targetName,
                			Typename:""
                		},
                		async:false,
                		dataType : 'text',
                		success : function(data) {
                			$.ajax({
                        		method : "post",
                        		url : "/pqs9000/devicereport/readpng",
                        		data : {},
                        		async:false,
                        		dataType : 'text',
                        		success : function(data) {

                        		}
                        	});
                		}
                	});
                }
            }
        }
    })
}

function getXbDl(startTime,endTime,lineId) {
	var type = '1';
	var targetName = "谐波电流频谱";
	var lineId = window.parent.document.getElementById("lineIndex").value;
    var startTime = $("#startTime").val();
    var endTime = $("#endTime").val();
    $.ajax({
        type : 'POST',
        url : '/pqs9000/device/getHarmI',
        data : {
            startTime:startTime,
            endTime:endTime,
            lineId:lineId,
            type:type
        },
        success : function(data) {
            var serName=[];
            var gb=[];
            var number=[];
            //没有权限的请求
            if(data==300){
                //没有登陆的请求
            }else if(data==301){
            }else {
                if (data.code == 500) {
                    for(i=1;i<50;i++){
                        serName.push([parseFloat(null)]);
                        gb.push([parseFloat(null)]);
                        number.push([i+1])
                    }
                    $("#container1").css("height",parent.picHeight*0.6);
                    //画图
                    var chart = Highcharts.chart('container1', {
                        credits: {
                            enabled: false
                        },
                        chart: {
                            type: 'column'
                        },
                        title: {
                            text: ''
                        },
                        xAxis: {
                            categories: number
                        },
                        yAxis: [{
                            min: 0,
                            title: {
                                text: '谐波电流幅值(A)'
                            }
                        }, {
                            title: {
                                text: '国标限值(A)'
                            },
                            opposite: true
                        }],
                        legend: {
                            shadow: false
                        },
                        tooltip: {
                            shared: true,
                            formatter:function () {
                                var x,y1,y2;
                                if(this.points.length==1){
                                    x="谐波次数："+this.points[0].x
                                    y2=this.points[0].series.name+":"+this.points[0].y+"A"
                                    return x+'<br>'+y2;
                                }else{
                                    x="谐波次数："+this.points[0].x
                                    y1="国标限值(A):"+this.points[0].y+"A"
                                    y2="谐波电流幅值(A):"+this.points[1].y+"A"
                                    return x+'<br>'+y1+'<br>'+y2;
                                }


                            }
                        },
                        plotOptions: {
                            column: {
                                grouping: false,
                                shadow: false,
                                borderWidth: 0
                            }
                        },
                        series: [{
                            name: '谐波电流幅值(A)',
                            color: yellow,
                            data: gb,
                            tooltip: {
                                valueSuffix: 'A'
                            },
                            pointPadding: 0.3,
                            pointPlacement: -0.2
                        }, {
                            name: '国标限值(A)',
                            color: green,
                            data: serName,
                            tooltip: {
                                valueSuffix: 'A'
                            },
                            pointPadding: 0.4, // 通过 pointPadding 和 pointPlacement 控制柱子位置
                            pointPlacement: -0.2

                        }]
                    });
                    var chartsvg=chart.getSVG();
                	$.ajax({
                		method : "post",
                		url : "/pqs9000/devicereport/changesvg",
                		data : {
                			charData:chartsvg,
                			targetName:targetName,
                			Typename:""
                		},
                		async:false,
                		dataType : 'text',
                		success : function(data) {
                			$.ajax({
                        		method : "post",
                        		url : "/pqs9000/devicereport/readpng",
                        		data : {},
                        		async:false,
                        		dataType : 'text',
                        		success : function(data) {

                        		}
                        	});
                		}
                	});
                } else {
                    for(i=1;i<50;i++){
                        serName.push([parseFloat(data.body[0][i])]);
                        gb.push([parseFloat(data.body[1][i])]);
                        number.push([i+1])
                    }
                    $("#container1").css("height",height*0.6);
                    //画图
                    var chart = Highcharts.chart('container1', {
                        credits: {
                            enabled: false
                        },
                        chart: {
                            type: 'column'
                        },
                        title: {
                            text: ''
                        },
                        xAxis: {
                            categories: number,
                        },
                        yAxis: [{
                            min: 0,
                            title: {
                                text: '谐波电流幅值(A)'
                            }
                        }, {
                            title: {
                                text: '国标限值(A)'
                            },
                            opposite: true
                        }],
                        legend: {
                            shadow: false
                        },
                        tooltip: {
                            shared: true,
                            formatter:function () {
                                var x,y1,y2;
                                if(this.points.length==1){
                                    x="谐波次数："+this.points[0].x
                                    y2=this.points[0].series.name+":"+this.points[0].y+"A"
                                    return x+'<br>'+y2;
                                }else{
                                    x="谐波次数："+this.points[0].x
                                    y1="国标限值(A):"+this.points[0].y+"A"
                                    y2="谐波电流幅值(A):"+this.points[1].y+"A"
                                    return x+'<br>'+y1+'<br>'+y2;
                                }


                            }
                        },
                        plotOptions: {
                            column: {
                                grouping: false,
                                shadow: false,
                                borderWidth: 0
                            }
                        },
                        series: [{
                            name: '谐波电流幅值(A)',
                            color: yellow,
                            data: gb,
                            tooltip: {
                                valueSuffix: 'A'
                            },
                            pointPadding: 0.3,
                            pointPlacement: -0.2
                        }, {
                            name: '国标限值(A)',
                            color: green,
                            data: serName,
                            tooltip: {
                                valueSuffix: 'A'
                            },
                            pointPadding: 0.4, // 通过 pointPadding 和 pointPlacement 控制柱子位置
                            pointPlacement: -0.2

                        }]
                    });
                    var chartsvg=chart.getSVG();
                	$.ajax({
                		method : "post",
                		url : "/pqs9000/devicereport/changesvg",
                		data : {
                			charData:chartsvg,
                			targetName:targetName,
                			Typename:""
                		},
                		async:false,
                		dataType : 'text',
                		success : function(data) {
                			$.ajax({
                        		method : "post",
                        		url : "/pqs9000/devicereport/readpng",
                        		data : {},
                        		async:false,
                        		dataType : 'text',
                        		success : function(data) {

                        		}
                        	});
                		}
                	});
                }
            }
        }
    })
}
