var path = window.location.href;// 获取界面路径
var lineIndex = window.parent.document.getElementById("lineIndex").value;
var allstime = window.parent.document.getElementById("allstime").value;
var alletime = window.parent.document.getElementById("alletime").value;
var checkpieces = window.parent.document.getElementById("checkpieces").value;
var checkpiecee = window.parent.document.getElementById("checkpiecee").value;
var allstartTime,allendTime;
var ismult,color;
/*******************************************************************************
 * z-tree控件基本参数设置
 ******************************************************************************/
var settingRight = {
	check : {
		enable : true,
		chkDisabledInherit : true
	},
	data : {
		simpleData : {
			enable : true
		}
	},
	callback : {
		beforeExpand : beforeExpand,
		beforeCheck : beforeCheck,
		onExpand : onExpand,
		onClick : onClick,
		onCheck : checkTarget
	}
};

//init method one
$(document).ready(function() {
    getThemeColor();
	if(lineIndex==null || lineIndex == ""){
		return;
	}
	createTime();
});

//获取主题颜色
function getThemeColor() {
    $.ajax({
        type: "POST",
        url: "/pqs9000/theme/getThemeInfo",
        async: false,
        dataType: 'json',
        success: function (data) {
            color = data.body.value;
        }
    })
}

var dateSilderObj;
//创建时间横轴提供用户选择时间节点
//月份定义
var Months = ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"];
function createTime(){
	$.ajax({
		type:'post',
		dataType : 'json',
		async : false,
		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()-700;
				$("#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;
//						$("#times").append('<el-radio-button class="primary" label="'+timestampToTime(allstartTime)+'-'+timestampToTime(allendTime)+
//								'"  onclick="creatSlider('+allstartTime+','+allendTime+')"></el-radio-button>');
						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);
						}
					}
				}

				// 监测点指标 tree的初始化
//				$.fn.zTree.init($("#target"), settingRight, zNodes);
				if (parent.pttype == 0) {
		            $.fn.zTree.init($("#target"), settingRight, zNodes);
		        } else {
		            $.fn.zTree.init($("#target"), settingRight, zNode);
		        }
				checkTarget();
				addOptions();
				loading = ityzl_SHOW_LOAD_LAYER();
				queryAndShowData();
			}
		}
	});

}


function creatGroups(timeseries){
	Highcharts.chart('container', {
		chart: {
			type: 'timeline',
			backgroundColor: '#F9F9F9',
			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;
	}
}

var loading;// 用于页面的loading
var bcheck = false;// 监测点选中状态
var num = 1;// 用于判断节点
// tree节点选中之前进行判断
var className = "dark";
var isType = true;//是否含有星型接线

function beforeCheck(treeId, treeNode) {
	className = (className === "dark" ? "" : "dark");
	return (treeNode.doCheck !== false);
}

// tree展开前处理事件
var curExpandNode = null;
// 用于判断检测点的个数
var pointNum = 1;

function beforeExpand(treeId, treeNode) {
    var pNode = curExpandNode ? curExpandNode.getParentNode() : null;
    var treeNodeP = treeNode.parentTId ? treeNode.getParentNode() : null;
    var zTree1 = $.fn.zTree.getZTreeObj("target");
    for (var i = 0, l = !treeNodeP ? 0 : treeNodeP.children.length; i < l; i++) {
        if (treeNode !== treeNodeP.children[i]) {
            zTree1.expandNode(treeNodeP.children[i], false);
        }
    }
    while (pNode) {
        if (pNode === treeNode) {
            break;
        }
        pNode = pNode.getParentNode();
    }
    if (!pNode) {
        singlePath(treeNode);
    }
}

// 改变设备树状态
function changeState(b) {
    bcheck = b;
    var zTree = $.fn.zTree.getZTreeObj("target");
    zTree.checkAllNodes(false);
    disabledNode(false);
    if (b) {
        num = 2;
        if(path.indexOf("his") != -1){
	        parent.triggerCheckBox(1);
	        parent.setTreeSelected(1, 3)
        }
        var numd = splitTree(num);
        getPttype(numd)
        if (isType) {
            var node = zTree.getNodeByParam("id", 11);
            zTree.checkNode(node, true, true);
        } else {
            var node = zTree.getNodeByParam("id", 12);
            zTree.checkNode(node, true, true);
        }
    } else {
        num = 1;
        if(path.indexOf("his") != -1){
	        parent.triggerCheckBox(2);
	        parent.setTreeSelected(2, 1)
        }
        var numd = splitTree(num);
        getPttype(numd)
        if (isType) {
            for (var i = 0; i < 3; i++) {
                var node = zTree.getNodeByParam("id", 11 + i);
                zTree.checkNode(node, true, true);
            }
        } else {
            for (var i = 0; i < 2; i++) {
                var node = zTree.getNodeByParam("id", 12 + i);
                zTree.checkNode(node, true, true);
            }
            var node = zTree.getNodeByParam("id", 17);
            zTree.checkNode(node, true, true);
        }
    }
    nodes = [];
    checkTarget();
}


//重新绘制tree内容 只展开一个tree根节点添加该事件
function singlePath(newNode) {
 if (newNode === curExpandNode)
     return;
 var zTree1 = $.fn.zTree.getZTreeObj("target"), rootNodes, tmpRoot, tmpTId, i, j, n;
 if (!curExpandNode) {
     tmpRoot = newNode;
     while (tmpRoot) {
         tmpTId = tmpRoot.tId;
         tmpRoot = tmpRoot.getParentNode();
     }
     rootNodes = zTree1.getNodes();
     for (i = 0, j = rootNodes.length; i < j; i++) {
         n = rootNodes[i];
         if (n.tId != tmpTId) {
             zTree1.expandNode(n, false);
         }
     }
 } else if (curExpandNode && curExpandNode.open) {
     if (newNode.parentTId === curExpandNode.parentTId) {
         zTree1.expandNode(curExpandNode, false);
     } else {
         var newParents = [];
         while (newNode) {
             newNode = newNode.getParentNode();
             if (newNode === curExpandNode) {
                 newParents = null;
                 break;
             } else if (newNode) {
                 newParents.push(newNode);
             }
         }
         if (newParents != null) {
             var oldNode = curExpandNode;
             var oldParents = [];
             while (oldNode) {
                 oldNode = oldNode.getParentNode();
                 if (oldNode) {
                     oldParents.push(oldNode);
                 }
             }
             if (newParents.length > 0) {
                 zTree1.expandNode(oldParents[Math.abs(oldParents.length
                     - newParents.length) - 1], false);
             } else {
                 zTree1.expandNode(oldParents[oldParents.length - 1], false);
             }
         }
     }
 }
 curExpandNode = newNode;
}

// 回调函数，展开tree节点
function onExpand(event, treeId, treeNode) {
    curExpandNode = treeNode;
}

// 回调函数，点击tree展开节点
function onClick(e, treeId, treeNode) {
    var zTree1 = $.fn.zTree.getZTreeObj("target");
    zTree1.expandNode(treeNode, null, null, null, true);
}

// 获取选中的监测点信息
function splitName(num) {
    var data;
    var name = new Array();
    if (num == 1) {
        data = parent.getTreeSelected(2);
    } else {
        data = parent.getTreeSelected(1);
    }
    for (var i = 0; i < data.length; i++) {
        name[i] = data[i].name;
    }
    pointNum = data.length;
    return name;
}

/*******************************************************************************
 * 获取查询指标 计算tree选中的节点，for循环去除计算父节点在内
 ******************************************************************************/
var checkCount = 1, totalcount = 4, nodes = '', node = null;

function checkTarget() {
    var zTree1 = $.fn.zTree.getZTreeObj("target");
    checkCount = zTree1.getCheckedNodes(true).length;
    node = zTree1.getCheckedNodes(true);
    totalcount = checkCount;
    nodes = '';
    var k = 0;
    for (var i = 0; i < totalcount; i++) {
        if (node[i].pId == null) {
            checkCount--;
        } else {
            if (!bcheck) {
                if (k < 3) {
                    nodes += node[i].id + ',';
                } else {
                    zTree1.checkNode(node[i], false, true);
                }
            } else {
                if (k < 1) {
                    nodes += node[i].id + ',';
                } else {
                    zTree1.checkNode(node[i], false, true);
                }
            }
            k++;
        }
        // 判断是否选中谐波指标
        if (nodes.indexOf('41') > -1 || nodes.indexOf('42') > -1) {
            document.getElementById('harmonicSelect').style.display = 'inline';
        } else {
            document.getElementById('harmonicSelect').style.display = 'none';
        }
    }
    if (nodes != '') {
        nodes = nodes.substring(0, nodes.lastIndexOf(','));
    }
    if (!bcheck) {
        if (k > 3) {
            layer.msg('最多选择3个指标');
        }
    } else {
        if (k > 1) {
            layer.msg('最多选择1个指标');
        }
    }

    if (!bcheck) {
        if (checkCount >= 3) {
            disabledNode(true);
        } else {
            disabledNode(false);
        }
    } else {
        if (checkCount >= 1) {
            disabledNode(true);
        } else {
            disabledNode(false);
        }
    }
}

function getPttype(point) {
    var list = new Object();
    list.point = point;
    var aoData = new Array();
    aoData.push(list)
    $.ajax({
        type: 'POST',
        async: false,
        url: '/pqs9000/device/getPttype',
        data: {
            obj: JSON.stringify(aoData)
        },
        success: function (data) {
            if (data.indexOf(0) != -1) {
                $.fn.zTree.init($("#target"), settingRight, zNodes);
                isType = true;
            } else {
                $.fn.zTree.init($("#target"), settingRight, zNode);
                isType = false;
            }
        }
    })
}

/*******************************************************************************
 * 给下拉框初始化数据
 ******************************************************************************/
function addOptions() {
    $("#harmonicId").empty();
    for (var i = 1; i < 51; i++) {
        if (i == 1) {
            document.getElementById('harmonicId').options.add(new Option('基波',
                i));
        } else {
            document.getElementById('harmonicId').options.add(new Option(i
                + '次', i));
        }
    }
}

// 根据检测点id获取监测点名称
function getName(index) {
    for (var i = 0; i < totalcount; i++) {
        if (node[i].id == index) {
            return ' ' + node[i].name;
        }
    }
    return ' ';
}

// 根据条件设置tree节点状态 可用/不可用
function disabledNode(e) {
    var zTree1 = $.fn.zTree.getZTreeObj("target"), l = zTree1
        .getCheckedNodes(false).length, nodes = zTree1
        .getCheckedNodes(false);
    nodeAll = zTree1.getNodes();
    m = zTree1.getNodes().length;
    if (e) {
        for (var i = 0; i < l; i++) {
            zTree1.setChkDisabled(nodes[i], e, false, false);
        }
    } else {
        for (var i = 0; i < m; i++) {
            zTree1.setChkDisabled(nodeAll[i], e, true, true);
        }
    }
}

/*******************************************************************************
 * 获取选中的监测点信息
 ******************************************************************************/
function splitTree(num) {
    var data;
    var index = '';
    if (num == 1) {
        data = parent.getTreeSelected(2);
    } else {
        data = parent.getTreeSelected(1);
    }
    for (var i = 0; i < data.length; i++) {
        index += data[i].nodeIndex + ',';
    }
    if (index != '') {
        index = index.substring(0, index.lastIndexOf(','));
    }
    return index;
}

var height = $(window).height();
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 obj_Search;// 查询条件汇总

/*******************************************************************************
 * 谐波次数切换刷新页面结果
 ******************************************************************************/

function harmonicState(value) {
    loading = ityzl_SHOW_LOAD_LAYER();
    harmonic = value;
    queryAndShowData();
}

/*******************************************************************************
 * 切换平均值、最大值、最小值、CP95值刷新页面结果
 ******************************************************************************/
function targetState(type) {
    obj_Search.valueType = type;
    loading = ityzl_SHOW_LOAD_LAYER();
    queryAndShowData();
}

$("#query").click(function () {
    loading = ityzl_SHOW_LOAD_LAYER();
    // 查询和展示
    queryAndShowData();
})

function deleteOption() {
    $("#interval option[value='年份']").remove();
    $("#interval option[value='季度']").remove();
}

/*******************************************************************************
 * 查询和数据展示 1、获取监测点和指标信息 2、判断查询时间是否合理 3、定义界面的布局 4、控制界面是否显示
 ******************************************************************************/
function queryAndShowData() {
    // 实例化参数，确保每次查询重置
    InstantiationParameter();
    // 控制查询框_不可用
    controlSearch(true);
    // 查询条件汇总
    obj_Search = new Object();
    // 1、判断监测点和指标信息
    if (checkPointandtarget()) {
        // 2、时间判断
        if (CheckDateTime()) {
            // 所有查询条件
            var aoData = new Array();
            aoData.push(obj_Search);
            getZj(aoData)
            // 3、限值获取
            if (getLimitRate(aoData)) {
                // 4、控制界面
                controlwindow();
                // 5、分割时间进行查询
                spitTime();
            }
        } else {
            controlSearch(false);
        }
    }

}

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

/*******************************************************************************
 * 关闭查询字段 blFlag ：true，false
 ******************************************************************************/
function controlSearch(blFlag) {
	if (path.indexOf("his") != -1) {
		document.getElementById("multiply").disabled = blFlag;
	}
	document.getElementById("query").disabled = blFlag;
	document.getElementById("choo").disabled = blFlag;
	document.getElementById("harmonicId").disabled = blFlag;
	document.getElementById("interval").disabled = blFlag;
}

/*******************************************************************************
 * 1、检查监测点和指标信息
 ******************************************************************************/
var harmonic = '1';

function checkPointandtarget() {
    var result = true;// 默认选择监测点和指标是符合的
    checkTarget();// 获取选中查询指标
    if (obj_Search != null) {
        // 获取值类型（最大、最小、平均，cp95）
        obj_Search.valueType = $("#choo").val();
        // 所选中监测点lineindex集合
        if (path.indexOf("his") != -1) {
            obj_Search.point = splitTree(num);
        } else {
            obj_Search.point = window.parent.document
                .getElementById("lineIndex").value;

        }
        // 所选中指标集合
        obj_Search.condition = nodes;
        // 如果有谐波电压或者谐波电流则增加一项属性
        if (obj_Search.condition.indexOf('41') > -1
            || obj_Search.condition.indexOf('42') > -1) {
            obj_Search.harmonic = harmonic;
        }
        // 展示图形个数，默认是一个
        obj_Search.historynum = 1;
    }

    if (obj_Search.point.length == 0) {
        layer.msg("请至少选择一个监测点!");
        controlSearch(false)
        result = false;
    }
    if (obj_Search.condition.length == 0) {
        layer.msg("请至少选择一个指标查询!");
        controlSearch(false)
        result = false;
    }
    return result;
}

/*******************************************************************************
 * 2、检查时间段确认
 ******************************************************************************/
function CheckDateTime() {
    var result = true;// 默认时间是负荷的
    var startTime = $("#startTime").val();// 起始时间
    var endTime = $("#endTime").val();// 结束时间

    if (!compareTime(startTime, endTime)) {
        layer.msg("时间设置错误,开始时间大于结束时间!");
        result = false;
    }
	if (obj_Search != null) {
		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));
	}
    return result;
}

/*******************************************************************************
 * 获取暂降触发点
 */
function getZj(aoData) {
    var result = true;
    $.ajax({
        type: 'POST',
        async: false,
        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);
        }
    })
}

/*******************************************************************************
 * 3、获取限值 *** aoData **** 查询条件
 ******************************************************************************/
function getLimitRate(aoData) {
    var result = true;
    $.ajax({
        type: 'POST',
        async: false,
        url: '/pqs9000/device/getXz',
        data: {
            obj: JSON.stringify(aoData)
        },
        error: function (data) {
            layer.msg("获取所选监测点限值失败，请联系管理员正确配置监测点信息！", {
                icon: 5,
                time: 3000
            });
            result = false;
            controlSearch(result);
        },
        success: function (data) {
            if (data.msg == "200") {
                // 数据返回集合长度
                var datalength = data.data.length;
                // 循环获取值
                for (var m = 0; m < datalength; m++) {
                    if (data.data[m] != null) {
                        var tmpObj_Limit = new Object();
                        // 获取频率限值
                        tmpObj_Limit.SfreqDev = 50 + data.data[m][0];
                        tmpObj_Limit.XfreqDev = 50 - data.data[m][0];
                        tmpObj_Limit.ubalance = data.data[m][1];
                        // 获取闪变限值
                        tmpObj_Limit.flicker = data.data[m][2];
                        tmpObj_Limit.uaberrance = data.data[m][3];
                        // 获取电压偏差限值
                        tmpObj_Limit.SvoltageDev = data.data[m][4];
                        tmpObj_Limit.XvoltageDev = -data.data[m][4];

                        // 获取谐波电压含有率和谐波电流幅值限值
                        var tmpUnum = 0, tmpInum = 0;
                        var Unum = new Array(24), Inum = new Array(24);
                        for (var n = 2; n < 26; n++) {
                            tmpUnum = n + 3;
                            tmpInum = n + 27;
                            Unum[n - 2] = data.data[m][tmpUnum];
                            Inum[n - 2] = data.data[m][tmpInum];
                        }
                        tmpObj_Limit.uharm = Unum;
                        tmpObj_Limit.iharm = Inum;

                        Obj_Limit.push(tmpObj_Limit);
                    }
                }
            }
        }
    });
    return result;
}

/*******************************************************************************
 * 4、界面控制 获取界面有效区域的大小 获取界面主要元素（画图区域）
 ******************************************************************************/
var picHeight = 0;// 界面有效区域大小
var width = 0;// 界面有效区域宽度
var container1, container2, container3, point;// 界面元素
function controlwindow() {
    var height = $("body").height();
    picHeight = height - 85;
    width = $("body").width();
    $("#echartId").css("width", width - 5);
    $("#echartId").css("maxHeight", picHeight);
    container1 = document.getElementById('container1');// 获得元素
    container2 = document.getElementById('container2');// 获得元素
    container3 = document.getElementById('container3');// 获得元素
    point = document.getElementById('point');
    $("#point").css("height", picHeight);
    $("#imgs").css("height", picHeight - 27)
}

/*******************************************************************************
 * 5、分段查询控制 xhday:分割时间（默认3天） 情况1：假如时间差小于分割时间，则一次查找好 情况2：假如时间差大于分割时间，则分批次查询
 ******************************************************************************/
var spitDays = 0;// 所选时间差：天
var xhcs = 0;// 分割查询次数，默认是0次表示不需要进行查询
var realxhcs = 0;// 实际需要循环次数
var pointmsg = 1;// 监测点个数
function spitTime() {
    // 取绝对值
    spitDays = daysBetween(obj_Search.startTime, obj_Search.endTime);
    // 初始化循环次数（默认一次就能查询结束）
    xhcs = 0;
    realxhcs = Math.ceil(spitDays / xhday);
    /***************************************************************************
     * 需要进行多次查询 需要重组时间
     **************************************************************************/
    if (realxhcs > 1) {
        obj_Search.endTime = dateAddDays(obj_Search.startTime, xhday);
    }
    // 所有查询条件
    var aoData = new Array();
    obj_Search.dataType = 1 //0,默认 在线 1，离线
    aoData.push(obj_Search);
    getData(aoData);
}

/*******************************************************************************
 * 6、数据查询 *** aoData **** 所有查询条件
 ******************************************************************************/
function getData(aoData) {
    if (path.indexOf("his") != -1) {
        var name = splitName(num);// 所选择的监测点
    } else {
        var name = window.parent.document.getElementById("lineName").value;
    }
    $.ajax({
        type: 'POST',
        async: true,
        url: '/pqs9000/device/getHistoryResult',
        data: {
            obj: JSON.stringify(aoData)
        },
        error: function (data) {
            layer.msg("未获取到历史数据", {
                icon: 5,
                time: 3000
            });
            controlSearch(false);
        },
        success: function (data) {
        	obj_Search.historynum = parseInt(data.msg);
            pointmsg = parseInt(data.msg1);
            analysisData(data, data.msg2);// 数据解析
            xhcs++;// 没查询一次则增加一个查询
            /*******************************************************************
             * 画图过滤代码 xhcs ==1 则执行画图操作 xhcs==realxhcs则表示所有数据取完毕，此时需要判断是否有数据 xhcs<realxhcs
             * 则执行更新图形操作
             ******************************************************************/
            if (xhcs == 1 && realxhcs == 0) {
                controlChart();// 控制界面图形展示
                drawCharts();
                isData();
                /***************************************************************
                 * 循环次数跟时间2间隔一样，则表示该所选的时间段小于时间间隔 则需要判断是否有数据，以及停止滚动条
                 **************************************************************/
                // todo
            } else if (xhcs < (realxhcs)) {
                controlChart();// 控制界面图形展示
                drawCharts();
                updateCharts();
            } else if (xhcs == realxhcs) {
                controlChart();// 控制界面图形展示
                // 更新图形
                drawCharts();
                isData();
                updateCharts();
                controlSearch(false);
                ityzl_CLOSE_LOAD_LAYER(loading);// 关闭loading
            }
        }
    })
}

/*******************************************************************************
 * 7、控制界面图形展示
 ******************************************************************************/
function controlChart() {
    switch (obj_Search.historynum) {
        case 1:
            container1.style.display = "block";
            container2.style.display = "none"
            container3.style.display = "none";
            point.style.display = "none";
            $("#container1").css("height", picHeight);
            break;
        case 2:
            container1.style.display = "block";
            container2.style.display = "block"
            container3.style.display = "none";
            point.style.display = "none";
            $("#container1").css("height", picHeight / 2);
            $("#container2").css("height", picHeight / 2);
            break;
        case 3:
            container1.style.display = "block";
            container2.style.display = "block"
            container3.style.display = "block";
            point.style.display = "none";
            $("#container1").css("height", picHeight / 2);
            $("#container2").css("height", picHeight / 2);
            $("#container3").css("height", picHeight / 2);
            break;
    }
}

/*******************************************************************************
 * 8、解析数据 *** data **** 返回数据
 ******************************************************************************/
// 暂降触发点最小值,对比所有的最小值，取ABC三项最小值
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 = [], tmax = [], amin = [], bmin = [], cmin = [], tmin = [], acp95 = [],
            bcp95 = [], ccp95 = [], tcp95 = [],
            avr = [], bvr = [], cvr = [], tvr = [], flicker = [], SfreqDev = [], XfreqDev = [], uaberrance = [],
            ubalance = [],
            SvoltageDev = [], XvoltageDev = [], iharm = [], uharm = [], fmax = [], fvr = [], fmin = [], fcp95 = [],
            zjamin = [], zjbmin = [], zjcmin = [], zjfmin = [];
        var ptts;
        var tmpTime;// 获取时间
        var tmpObj_Limit = null;
        // 单检测点情况
        if (num == 1)
            tmpObj_Limit = Obj_Limit[0];
        else
            tmpObj_Limit = Obj_Limit[m];

        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][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(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)]]);
                        }
                    }
                }
                ptts = tmpData[0][6];
                // 获取暂降触发点信息
                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);
                // 监测点个数
                if (tmpData[0].length == 1) {// 一个监测点
                    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;
                    }
                } else if (tmpData[0].length == 2) {// 二个监测点
                    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;
                    }
                    eIndex = [], eTime = [];
                    if (tmpData[0][1] != null) {
                        for (var i = 0; i < tmpData[0][1].length; i++) {
                            eIndex.push(tmpData[0][1][i][0]);
                            eTime.push([parseFloat(tmpData[0][1][i][1]),
                                yevent_value])
                        }
                        tmpObj_Data[24] = eIndex;
                        tmpObj_Data[25] = eTime;
                    } else {
                        tmpObj_Data[24] = eIndex;
                        tmpObj_Data[25] = eTime;
                    }
                } else if (tmpData[0].length == 3) {// 三个监测点
                    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;
                    }
                    eIndex = [], eTime = [];
                    if (tmpData[0][1] != null) {
                        for (var i = 0; i < tmpData[0][1].length; i++) {
                            eIndex.push(tmpData[0][1][i][0]);
                            eTime.push([parseFloat(tmpData[0][1][i][1]),
                                yevent_value])
                        }
                        tmpObj_Data[24] = eIndex;
                        tmpObj_Data[25] = eTime;
                    } else {
                        tmpObj_Data[24] = eIndex;
                        tmpObj_Data[25] = eTime;
                    }
                    eIndex = [], eTime = [];
                    if (tmpData[0][2] != null) {
                        for (var i = 0; i < tmpData[0][2].length; i++) {
                            eIndex.push(tmpData[0][2][i][0]);
                            eTime.push([parseFloat(tmpData[0][2][i][1]),
                                yevent_value])
                        }
                        tmpObj_Data[26] = eIndex;
                        tmpObj_Data[27] = eTime;
                    } else {
                        tmpObj_Data[26] = eIndex;
                        tmpObj_Data[27] = eTime;
                    }
                }
                // 临时数据赋值
                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[15] = ubalance;// 三相电压不平衡度
                tmpObj_Data[28] = ptts;//接线方式
                splitObj_History[m] = (tmpObj_Data);
                // 把每次查询到的整体数据赋值给全局变量（给切换时候用）
                var tmpObj_History = obj_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[3] = tmpObj_History[3].concat(fcp95);
                    tmpObj_History[12] = tmpObj_History[12].concat(XfreqDev);
                    tmpObj_History[13] = tmpObj_History[13].concat(SfreqDev);
                    tmpObj_History[15] = tmpObj_History[15].concat(ubalance);
                    tmpObj_History[28] = ptts;
                    obj_History[m] = tmpObj_History;// 重新给该位置赋值
                }
                // 假如为空则执行插入
                else {
                    obj_History.push(tmpObj_Data);
                }
            } else {
                // 数据解析
                for (var i = 0; i < tmpData.length; i++) {

                    tmpTime = parseFloat(tmpData[i][1]);
                    // 平均值
                    if (tmpData[0][0] == 61 || tmpData[0][0] == 62 || tmpData[0][0] == 63) {
                        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][2])]);
                        bmin.push([tmpTime, parseFloat(tmpData[i][3])]);
                        cmin.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]));
                    } else {
                        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]]);
                        }
                    }
                }
                ptts = tmpData[0][14];
                // 获取暂降触发点信息
                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);
                // 监测点个数
                if (tmpData[0].length == 1) {// 一个监测点
                    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;
                    }
                } else if (tmpData[0].length == 2) {// 二个监测点
                    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;
                    }
                    eIndex = [], eTime = [];
                    if (tmpData[0][1] != null) {
                        for (var i = 0; i < tmpData[0][1].length; i++) {
                            eIndex.push(tmpData[0][1][i][0]);
                            eTime.push([parseFloat(tmpData[0][1][i][1]),
                                yevent_value])
                        }
                        tmpObj_Data[24] = eIndex;
                        tmpObj_Data[25] = eTime;
                    } else {
                        tmpObj_Data[24] = eIndex;
                        tmpObj_Data[25] = eTime;
                    }
                } else if (tmpData[0].length == 3) {// 三个监测点
                    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;
                    }
                    eIndex = [], eTime = [];
                    if (tmpData[0][1] != null) {
                        for (var i = 0; i < tmpData[0][1].length; i++) {
                            eIndex.push(tmpData[0][1][i][0]);
                            eTime.push([parseFloat(tmpData[0][1][i][1]),
                                yevent_value])
                        }
                        tmpObj_Data[24] = eIndex;
                        tmpObj_Data[25] = eTime;
                    } else {
                        tmpObj_Data[24] = eIndex;
                        tmpObj_Data[25] = eTime;
                    }
                    eIndex = [], eTime = [];
                    if (tmpData[0][2] != null) {
                        for (var i = 0; i < tmpData[0][2].length; i++) {
                            eIndex.push(tmpData[0][2][i][0]);
                            eTime.push([parseFloat(tmpData[0][2][i][1]),
                                yevent_value])
                        }
                        tmpObj_Data[26] = eIndex;
                        tmpObj_Data[27] = eTime;
                    } else {
                        tmpObj_Data[26] = eIndex;
                        tmpObj_Data[27] = eTime;
                    }
                }
                // 临时数据赋值
                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;
                tmpObj_Data[28] = ptts;
                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);
                    tmpObj_History[28] = ptts;
                    obj_History[m] = tmpObj_History;// 重新给该位置赋值
                }
                // 假如为空则执行插入
                else {
                    obj_History.push(tmpObj_Data);
                }
            }
        } else {
            obj_History.push(null);
        }
    }
}

/*******************************************************************************
 * 9、新增图形
 ******************************************************************************/
function drawCharts() {
    objdata = [];
    $('#container1').html("");
    $('#container2').html("");
    $('#container3').html("");
    if (obj_History.length > 0) {
        if (path.indexOf("his") != -1) {
            var name = splitName(num);// 所选择的监测点
        } else {
            var name = window.parent.document.getElementById("lineName").value;

        }
        var targetName;// 所选择指标名称
        var targetId = obj_Search.condition.split(",");
        // 单监测点多指标情况
        if (targetId.length >= 1 && pointNum == 1) {
            for (var i = 0; i < targetId.length; i++) {
                targetName = getTargetName(targetId[i]);// 获取指标名称
                objdata = obj_History[i];
                pushWaveData(targetName, objdata, i);

                initWave(name, targetName, i, objdata);
            }
        }
        // 多监测点单指标情况
        else if (targetId.length == 1 && pointNum > 1) {
            targetName = getTargetName(targetId);// 获取指标名称
            for (var i = 0; i < pointNum; i++) {
                objdata = obj_History[i];
                pushWaveData(targetName, objdata, i);
                initWave(name[i], targetName, i, objdata);
            }
        }
    }

    // 分割查询控制
    controlSplitSearch();
}

/*******************************************************************************
 * 全屏展示
 ******************************************************************************/

function isFull() {

    var explorer = window.navigator.userAgent.toLowerCase();

    var full;

    if (explorer.indexOf('chrome') > 0) {// chrome
        if (document.body.scrollHeight == window.screen.height
            && document.body.scrollWidth == window.screen.width) {

            full = true;

        } else {

            full = false;

        }

    } else {// IE 9+ fireFox

        if (window.outerHeight == window.screen.height
            && window.outerWidth == window.screen.width) {

            full = true;

        } else {

            full = false;

        }

    }
    ;

    return full;

};
$('#btnfullScreen').click(function () {

    var screen = isFull();

    if (screen) {

        exitScreen();

    } else {

        fullScreen();

    }

});

// 网页全屏代码

function fullScreen() {

    // ie10以下全屏模式

    if (window.ActiveXObject) {

        var wscript = new ActiveXObject("WScript.Shell");

        if (wscript) {

            wscript.SendKeys("{F11}");

            return;

        }

    }
    ;

    // 判断各种浏览器，找到正确的方法

    function fullScreen(obj) {

        if (obj.requestFullscreen) {

            obj.requestFullscreen();

        } else if (obj.mozRequestFullScreen) {

            obj.mozRequestFullScreen();

        } else if (obj.webkitRequestFullscreen) {

            obj.webkitRequestFullscreen();

        } else if (obj.msRequestFullscreen) {

            obj.msRequestFullscreen();

        }

    }
    ;

    // 启动全屏

    // fullScreen($('html').get(0)); // 整个网页

    fullScreen(document.getElementById("echartId")); // 某个页面元素

};

/*******************************************************************************
 * 初始化图形
 *
 * @param name
 *            监测点名称
 * @param targetName
 *            所选指标名称
 * @param number
 *            绘制图形的个数（1,2,3）
 * @param data
 *            所传入数据
 ******************************************************************************/
function initWave(name, targetName, number, data) {
    var index1 = [];
    var zj = [], getZj = [], zmin = [];
    var unit = getUnit(targetName);// 获取展示Y单位
    $("#echartId").css("height", height);
    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
        }
    });
    Highcharts.stockChart('container' + (number + 1), {
        title: {
            text: name + " " + targetName
        },
        subtitle: {
            text: titleName,
            style: {
                color: "#ff0000"
            }
        },
        dataLabels: {
            allowOverlap: true
        },
        //导出选中背景色
        navigation: {
            menuItemHoverStyle: {
                background: color,
                color: "#ffffff"
            },
        },
        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[number]
        },
        plotOptions: {
            line: {
                dataGrouping: {
                    enabled: false
                }
            }
        },
        rangeSelector: {
            enabled: false
        },
        scrollbar: {
            enabled: false
        },
        exporting: {
            enabled: true,   // 开启导出按钮
            filename: name + " " + targetName,
        },
        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: {
                formatter: function () {
                    return Highcharts.numberFormat(this.value, 3);
                },
            },
            opposite: false
        },
        legend: {
            align: 'left',
            verticalAlign: 'top',
            left: '10%',
            enabled: true
        },
        series: series_Data[number]
    });
    $('.bxfx').on(
        'mousemove',
        function (e) {
            var sourceChartContainer = $(this);
            // 获取所有highcharts对象
            var sourceChart = sourceChartContainer.highcharts();
            // x坐标轴
            var sourceXAxis = sourceChart.xAxis[0];
            // 获取极值
            var extremes = sourceXAxis.getExtremes();
            // 遍历同节点元素 即highcharts元素块
            var targetChartContainerList = sourceChartContainer
                .siblings('.bxfx');

            // 遍历进行处理
            targetChartContainerList.each(function (num,
                                                    targetChartContainerElement) {
                var targetChartContainer = $(targetChartContainerElement);
                // 获取highcharts对象
                var targetChart = targetChartContainer.highcharts();
                // 偏移值
                var sourceOffset = sourceChartContainer.offset();
                var targetOffset = targetChartContainer.offset();
                var targetE = {};

                targetE.pageX = e.pageX + targetOffset.left
                    - sourceOffset.left;
                targetE.pageY = e.pageY + targetOffset.top
                    - sourceOffset.top;
                var targetE = targetChartContainer
                        .find('rect.highcharts-background')[0]
                    || targetChartContainer
                        .find('path.highcharts-tracker')[0];

                if (targetChart && targetChart.pointer) {
                    var el = targetChart.pointer.normalize(e); // Find
                    if (targetChart.series.length == 0) {
                        if (targetChart.series[num] != undefined) {
                            var point = targetChart.series[1].searchPoint(
                                el, true); // Get
                            if (point) {
                                point.onMouseOver(); // Show the hover
                                // marker
                            }
                        }
                    } else {
                        if (targetChart.series[num] != undefined) {
                            var point = targetChart.series[1].searchPoint(
                                el, true); // Get
                            if (point) {
                                point.onMouseOver(); // Show the hover
                                // marker
                            }
                        }
                    }
                }
            });
        })
}

/*******************************************************************************
 * 初始化数据，当没有数据时画一张无数据的图 obj_History[0]、obj_History[1]、obj_History[2]指的是数据
 * obj_History[0].length == 0,说明该监测点在该指标、在该时间内没有数据
 */
function isData() {
	if (xhcs == realxhcs) {
        if (obj_History[0] == null && obj_History[1] == null && obj_History[2] == null) {
            layer.msg("没有获取到该监测点的历史数据", {
                icon: 5,
                time: 3000
            });
            container1.style.display = "none";
            container2.style.display = "none";
            container3.style.display = "none";
            point.style.display = "block";
            controlSearch(false);
        }
        ityzl_CLOSE_LOAD_LAYER(loading);// 关闭loading
    } else if (realxhcs == 0) {
        if (obj_History[0] == null && obj_History[1] == null && obj_History[2] == null) {
            layer.msg("没有获取到该监测点的历史数据", {
                icon: 5,
                time: 3000
            });
            container1.style.display = "none";
            container2.style.display = "none";
            container3.style.display = "none";
            point.style.display = "block";
        }
        ityzl_CLOSE_LOAD_LAYER(loading);// 关闭loading
    } else {
        if (obj_History[0] == null && obj_History[1] == null && obj_History[2] == null) {
            container1.style.display = "none";
            container2.style.display = "none";
            container3.style.display = "none";
            point.style.display = "block";
        }
        ityzl_CLOSE_LOAD_LAYER(loading);// 关闭loading
    }
    if (realxhcs == 0 || realxhcs == xhcs) {
        controlSearch(false);
        ityzl_CLOSE_LOAD_LAYER(loading);// 关闭loading
    }
}

/*******************************************************************************
 * 根据所选择的数据类型进行数据切换
 *
 * @param targetName
 *            所选择的目标名称
 * @param data
 *            传入数据
 * @param number
 *            绘图个数（1,2,3）
 ******************************************************************************/
var iv = [];
var zj = [];

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 == "三相电压不平衡度") {
                if (data[28] == 1 || data[28] == 2) {
                    if (data[28] == 1) {
                        titleName = "该监测点为三角型接线，" + targetName + "没有数据";
                    } else {
                        titleName = "该监测点为V型接线，" + targetName + "没有数据";
                    }
                } else {
                    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 == "电压总谐波畸变率") {
            if (data[28] == 1) {
                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]
                });
                tmpSeries_Data.push({
                    "name": "BC相",
                    "data": data[subdata + 4]

                });
                tmpSeries_Data.push({
                    "name": "CA相",
                    "data": data[subdata + 8]
                });
                tmpSeries_Data.push({
                    "dashStyle": "shortdash",
                    "name": "上限",
                    "data": data[14]
                });
                colo.push(yellow, green, red, red);
            } else if (data[28] == 2) {
                tmpSeries_Nav.push({
                    "data": data[subdata + 0]
                });
                tmpSeries_Nav.push({
                    "data": data[subdata + 4]
                });
                tmpSeries_Data.push({
                    "name": "AB相",
                    "data": data[subdata]
                });
                tmpSeries_Data.push({
                    "name": "CB相",
                    "data": data[subdata + 4]

                });
                tmpSeries_Data.push({
                    "dashStyle": "shortdash",
                    "name": "上限",
                    "data": data[14]
                });
                colo.push(yellow, green, 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]
                });
                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;
            if (data[28] == 1) {
                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]
                });
                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 (data[28] == 2) {
                tmpSeries_Nav.push({
                    "data": data[subdata + 0]
                });
                tmpSeries_Nav.push({
                    "data": data[subdata + 4]
                });
                tmpSeries_Data.push({
                    "name": "AB相",
                    "data": data[subdata + 0]
                });
                tmpSeries_Data.push({
                    "name": "CB相",
                    "data": data[subdata + 4]
                });
                tmpSeries_Data.push({
                    "dashStyle": "shortdash",
                    "name": "上限",
                    "data": data[17]
                });
                tmpSeries_Data.push({
                    "dashStyle": "shortdash",
                    "name": "下限",
                    "data": data[16]
                });
                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]
                });
                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 = "该指标只有平均值";
            if (data[28] == 1) {
                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": "AB相",
                    "data": data[subdata + 0],
                    "step": "middle"
                });
                tmpSeries_Data.push({
                    "name": "BC相",
                    "data": data[subdata + 4],
                    "step": "middle"
                });
                tmpSeries_Data.push({
                    "name": "CA相",
                    "data": data[subdata + 8],
                    "step": "middle"
                });
                tmpSeries_Data.push({
                    "dashStyle": "shortdash",
                    "name": "上限",
                    "data": data[18]

                });
                colo.push(yellow, green, red, red);
            } else if (data[28] == 2) {
                tmpSeries_Nav.push({
                    "data": data[subdata + 0],
                    "step": "middle"
                });
                tmpSeries_Nav.push({
                    "data": data[subdata + 4],
                    "step": "middle"
                });
                tmpSeries_Data.push({
                    "name": "AB相",
                    "data": data[subdata + 0],
                    "step": "middle"
                });
                tmpSeries_Data.push({
                    "name": "CB相",
                    "data": data[subdata + 4],
                    "step": "middle"
                });
                tmpSeries_Data.push({
                    "dashStyle": "shortdash",
                    "name": "上限",
                    "data": data[18]

                });
                colo.push(yellow, green, red);
            } else {
                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 = "该指标只有平均值";
            if (data[28] == 1) {
                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": "AB相",
                    "data": data[subdata + 0],
                    "step": "middle"
                });
                tmpSeries_Data.push({
                    "name": "BC相",
                    "data": data[subdata + 4],
                    "step": "middle"
                });
                tmpSeries_Data.push({
                    "name": "CA相",
                    "data": data[subdata + 8],
                    "step": "middle"
                });
                colo.push(yellow, green, red);
            } else if (data[28] == 2) {
                tmpSeries_Nav.push({
                    "data": data[subdata + 0],
                    "step": "middle"
                });
                tmpSeries_Nav.push({
                    "data": data[subdata + 4],
                    "step": "middle"
                });
                tmpSeries_Data.push({
                    "name": "AB相",
                    "data": data[subdata + 0],
                    "step": "middle"
                });
                tmpSeries_Data.push({
                    "name": "CB相",
                    "data": data[subdata + 4],
                    "step": "middle"
                });
                colo.push(yellow, green);
            } else {
                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 == "线电压有效值") {
            if (data[28] == 1) {
                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 (data[28] == 2) {
                tmpSeries_Nav.push({
                    "data": data[subdata + 0]
                });
                tmpSeries_Nav.push({
                    "data": data[subdata + 4]
                });
                tmpSeries_Data.push({
                    "name": "AB相",
                    "data": data[subdata + 0]
                });
                tmpSeries_Data.push({
                    "name": "CB相",
                    "data": data[subdata + 4]
                });
                colo.push(yellow, green);
            } 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": "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 == "电压不平衡度") {
            if (data[28] == 1 || data[28] == 2) {
                if (data[28] == 1) {
                    titleName = "该监测点为三角型接线，" + targetName + "没有数据";
                } else {
                    titleName = "该监测点为V型接线，" + targetName + "没有数据";
                }
            } 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": "零序电压(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 (data[28] == 1) {
                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": "AB相",
                        "data": data[subdata + 0]
                    });
                    tmpSeries_Data.push({
                        "name": "BC相",
                        "data": data[subdata + 4]
                    });
                    tmpSeries_Data.push({
                        "name": "CA相",
                        "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": "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 (data[28] == 2) {
                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": "AB相",
                        "data": data[subdata + 0]
                    });
                    tmpSeries_Data.push({
                        "name": "CB相",
                        "data": data[subdata + 4]
                    });
                    tmpSeries_Data.push({
                        "dashStyle": "shortdash",
                        "name": parseInt(obj_Search.harmonic) + "次上限",
                        "data": data[19]
                    });
                    colo.push(yellow, green, red);
                } else {
                    tmpSeries_Nav.push({
                        "data": data[subdata + 0]
                    });
                    tmpSeries_Nav.push({
                        "data": data[subdata + 4]
                    });
                    tmpSeries_Data.push({
                        "name": "AB相",
                        "data": data[subdata + 0]
                    });
                    tmpSeries_Data.push({
                        "name": "CB相",
                        "data": data[subdata + 4]
                    });
                    colo.push(yellow, green);
                }
            } else {
                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]
            });
            if (targetName == "三相总有功功率") {
                tmpSeries_Data.push({
                    "name": "总有功功率",
                    "data": data[subdata + 0]
                });
            } else if (targetName == "三相总无功功率") {
                tmpSeries_Data.push({
                    "name": "总无功功率",
                    "data": data[subdata + 0]
                });
            } else if (targetName == "三相总视在功率") {
                tmpSeries_Data.push({
                    "name": "总视在功率",
                    "data": data[subdata + 0]
                });
            }
            colo.push(black);
        } else if (targetName == "三相有功功率" || targetName == "三相无功功率" || targetName == "三相视在功率") {
            if (data[28] == 1 || data[28] == 2) {
                if (data[28] == 1) {
                    titleName = "该监测点为三角型接线，" + targetName + "没有数据";
                } else {
                    titleName = "该监测点为V型接线，" + targetName + "没有数据";
                }
            } 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 (data[28] == 1 || data[28] == 2) {
                if (data[28] == 1) {
                    titleName = "该监测点为三角型接线，" + targetName + "没有数据";
                } else {
                    titleName = "该监测点为V型接线，" + targetName + "没有数据";
                }
            } 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 {
            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) {
                zj = data[22];
                tmpSeries_Data.push({
                    "type": "scatter",
                    "name": "暂降触发点",
                    "marker": {
                        symbol: 'url(/pqs9000/images/point.png)',
                        width: 16,
                        height: 16
                    },
                    "data": zj,
                    "events": {
                        cursor: 'pointer',
                        click: function (e) {
                            var eventIndex = data[21][e.point.index];
                            layer
                                .open({
                                    type: 2,
                                    title: '波形分析',
                                    maxmin: false,
                                    shadeClose: true, // 点击遮罩关闭层
                                    area: ['100%', '100%'],
                                    content: 'vdwaveform?eventIndex='
                                        + eventIndex,
                                    scrollbar: false
                                });
                        }
                    }
                });
                colo.push(red)
            }
        } else if (data[23] == 2) {// 二个监测点
            if (data[28] == 1 || data[28] == 2) {
                if (number == 0) {
                    if (targetName == "相电压有效值" || targetName == "三相电压不平衡度" || targetName == "电压不平衡" || targetName == "三相总有功功率" || targetName == "三相总无功功率" || targetName == "三相总视在功率") {

                    } else {
                        if ((number + 1) == 1) {
                            zj = data[22];
                            tmpSeries_Data.push({
                                "type": "scatter",
                                "name": "暂降触发点",
                                "marker": {
                                    symbol: 'url(/pqs9000/images/point.png)',
                                    width: 16,
                                    height: 16
                                },
                                "data": zj,
                                "events": {
                                    cursor: 'pointer',
                                    click: function (e) {
                                        var eventIndex = data[21][e.point.index];
                                        layer
                                            .open({
                                                type: 2,
                                                title: '波形分析',
                                                maxmin: false,
                                                shadeClose: true, // 点击遮罩关闭层
                                                area: ['100%', '100%'],
                                                content: 'vdwaveform?eventIndex='
                                                    + eventIndex,
                                                scrollbar: false
                                            });
                                    }
                                }
                            });
                            colo.push(red)
                        } else if (number + 1 == 2) {
                            zj = data[25];
                            tmpSeries_Data.push({
                                "type": "scatter",
                                "name": "暂降触发点",
                                "marker": {
                                    symbol: 'url(/pqs9000/images/point.png)',
                                    width: 16,
                                    height: 16
                                },
                                "data": zj,
                                "events": {
                                    cursor: 'pointer',
                                    click: function (e) {
                                        var eventIndex = data[24][e.point.index];
                                        layer
                                            .open({
                                                type: 2,
                                                title: '波形分析',
                                                maxmin: false,
                                                shadeClose: true, // 点击遮罩关闭层
                                                area: ['100%', '100%'],
                                                content: 'vdwaveform?eventIndex='
                                                    + eventIndex,
                                                scrollbar: false
                                            });
                                    }
                                }
                            });
                            colo.push(red)
                        }
                    }
                } else {
                    if (targetName == "相电压有效值" || targetName == "三相电压不平衡度" || targetName == "电压不平衡" || targetName == "三相总有功功率" || targetName == "三相总无功功率" || targetName == "三相总视在功率") {

                    } else {
                        if ((number + 1) == 1) {
                            zj = data[22];
                            tmpSeries_Data.push({
                                "type": "scatter",
                                "name": "暂降触发点",
                                "marker": {
                                    symbol: 'url(/pqs9000/images/point.png)',
                                    width: 16,
                                    height: 16
                                },
                                "data": zj,
                                "events": {
                                    cursor: 'pointer',
                                    click: function (e) {
                                        var eventIndex = data[21][e.point.index];
                                        layer
                                            .open({
                                                type: 2,
                                                title: '波形分析',
                                                maxmin: false,
                                                shadeClose: true, // 点击遮罩关闭层
                                                area: ['100%', '100%'],
                                                content: 'vdwaveform?eventIndex='
                                                    + eventIndex,
                                                scrollbar: false
                                            });
                                    }
                                }
                            });
                            colo.push(red)
                        } else if (number + 1 == 2) {
                            zj = data[25];
                            tmpSeries_Data.push({
                                "type": "scatter",
                                "name": "暂降触发点",
                                "marker": {
                                    symbol: 'url(/pqs9000/images/point.png)',
                                    width: 16,
                                    height: 16
                                },
                                "data": zj,
                                "events": {
                                    cursor: 'pointer',
                                    click: function (e) {
                                        var eventIndex = data[24][e.point.index];
                                        layer
                                            .open({
                                                type: 2,
                                                title: '波形分析',
                                                maxmin: false,
                                                shadeClose: true, // 点击遮罩关闭层
                                                area: ['100%', '100%'],
                                                content: 'vdwaveform?eventIndex='
                                                    + eventIndex,
                                                scrollbar: false
                                            });
                                    }
                                }
                            });
                            colo.push(red)
                        }
                    }
                }
            } else {
                if ((number + 1) == 1) {
                    zj = data[22];
                    tmpSeries_Data.push({
                        "type": "scatter",
                        "name": "暂降触发点",
                        "marker": {
                            symbol: 'url(/pqs9000/images/point.png)',
                            width: 16,
                            height: 16
                        },
                        "data": zj,
                        "events": {
                            cursor: 'pointer',
                            click: function (e) {
                                var eventIndex = data[21][e.point.index];
                                layer
                                    .open({
                                        type: 2,
                                        title: '波形分析',
                                        maxmin: false,
                                        shadeClose: true, // 点击遮罩关闭层
                                        area: ['100%', '100%'],
                                        content: 'vdwaveform?eventIndex='
                                            + eventIndex,
                                        scrollbar: false
                                    });
                            }
                        }
                    });
                    colo.push(red)
                } else if (number + 1 == 2) {
                    zj = data[25];
                    tmpSeries_Data.push({
                        "type": "scatter",
                        "name": "暂降触发点",
                        "marker": {
                            symbol: 'url(/pqs9000/images/point.png)',
                            width: 16,
                            height: 16
                        },
                        "data": zj,
                        "events": {
                            cursor: 'pointer',
                            click: function (e) {
                                var eventIndex = data[24][e.point.index];
                                layer
                                    .open({
                                        type: 2,
                                        title: '波形分析',
                                        maxmin: false,
                                        shadeClose: true, // 点击遮罩关闭层
                                        area: ['100%', '100%'],
                                        content: 'vdwaveform?eventIndex='
                                            + eventIndex,
                                        scrollbar: false
                                    });
                            }
                        }
                    });
                    colo.push(red)
                }
            }
        } else if (data[23] == 3) {// 三个监测点
            if (data[28] == 1 || data[28] == 2) {
                if (number == 0) {
                    if (targetName == "相电压有效值" || targetName == "三相电压不平衡度" || targetName == "电压不平衡" || targetName == "三相总有功功率" || targetName == "三相总无功功率" || targetName == "三相总视在功率") {

                    } else {
                        if ((number + 1) == 1) {
                            zj = data[22];
                            tmpSeries_Data.push({
                                "type": "scatter",
                                "name": "暂降触发点",
                                "marker": {
                                    symbol: 'url(/pqs9000/images/point.png)',
                                    width: 16,
                                    height: 16
                                },
                                "data": zj,
                                "events": {
                                    cursor: 'pointer',
                                    click: function (e) {
                                        var eventIndex = data[21][e.point.index];
                                        layer
                                            .open({
                                                type: 2,
                                                title: '波形分析',
                                                maxmin: false,
                                                shadeClose: true, // 点击遮罩关闭层
                                                area: ['100%', '100%'],
                                                content: 'vdwaveform?eventIndex='
                                                    + eventIndex,
                                                scrollbar: false
                                            });
                                    }
                                }
                            });
                            colo.push(red)
                        } else if (number + 1 == 2) {
                            zj = data[25];
                            tmpSeries_Data.push({
                                "type": "scatter",
                                "name": "暂降触发点",
                                "marker": {
                                    symbol: 'url(/pqs9000/images/point.png)',
                                    width: 16,
                                    height: 16
                                },
                                "data": zj,
                                "events": {
                                    cursor: 'pointer',
                                    onclick: function (e) {
                                        var eventIndex = data[24][e.point.index];
                                        layer
                                            .open({
                                                type: 2,
                                                title: '波形分析',
                                                maxmin: false,
                                                shadeClose: true, // 点击遮罩关闭层
                                                area: ['100%', '100%'],
                                                content: 'vdwaveform?eventIndex='
                                                    + eventIndex,
                                                scrollbar: false
                                            });
                                    }
                                }
                            });
                            colo.push(red)
                        } else {
                            zj = data[27];
                            tmpSeries_Data.push({
                                "type": "scatter",
                                "name": "暂降触发点",
                                "marker": {
                                    symbol: 'url(/pqs9000/images/point.png)',
                                    width: 16,
                                    height: 16
                                },
                                "data": zj,
                                "events": {
                                    cursor: 'pointer',
                                    onclick: function (e) {
                                        var eventIndex = data[26][e.point.index];
                                        layer
                                            .open({
                                                type: 2,
                                                title: '波形分析',
                                                maxmin: false,
                                                shadeClose: true, // 点击遮罩关闭层
                                                area: ['100%', '100%'],
                                                content: 'vdwaveform?eventIndex='
                                                    + eventIndex,
                                                scrollbar: false
                                            });
                                    }
                                }
                            });
                            colo.push(red)
                        }
                    }
                } else {
                    if (targetName == "相电压有效值" || targetName == "三相电压不平衡度" || targetName == "电压不平衡" || targetName == "三相总有功功率" || targetName == "三相总无功功率" || targetName == "三相总视在功率") {

                    } else {
                        if ((number + 1) == 1) {
                            zj = data[22];
                            tmpSeries_Data.push({
                                "type": "scatter",
                                "name": "暂降触发点",
                                "marker": {
                                    symbol: 'url(/pqs9000/images/point.png)',
                                    width: 16,
                                    height: 16
                                },
                                "data": zj,
                                "events": {
                                    cursor: 'pointer',
                                    click: function (e) {
                                        var eventIndex = data[21][e.point.index];
                                        layer
                                            .open({
                                                type: 2,
                                                title: '波形分析',
                                                maxmin: false,
                                                shadeClose: true, // 点击遮罩关闭层
                                                area: ['100%', '100%'],
                                                content: 'vdwaveform?eventIndex='
                                                    + eventIndex,
                                                scrollbar: false
                                            });
                                    }
                                }
                            });
                            colo.push(red)
                        } else if (number + 1 == 2) {
                            zj = data[25];
                            tmpSeries_Data.push({
                                "type": "scatter",
                                "name": "暂降触发点",
                                "marker": {
                                    symbol: 'url(/pqs9000/images/point.png)',
                                    width: 16,
                                    height: 16
                                },
                                "data": zj,
                                "events": {
                                    cursor: 'pointer',
                                    onclick: function (e) {
                                        var eventIndex = data[24][e.point.index];
                                        layer
                                            .open({
                                                type: 2,
                                                title: '波形分析',
                                                maxmin: false,
                                                shadeClose: true, // 点击遮罩关闭层
                                                area: ['100%', '100%'],
                                                content: 'vdwaveform?eventIndex='
                                                    + eventIndex,
                                                scrollbar: false
                                            });
                                    }
                                }
                            });
                            colo.push(red)
                        } else {
                            zj = data[27];
                            tmpSeries_Data.push({
                                "type": "scatter",
                                "name": "暂降触发点",
                                "marker": {
                                    symbol: 'url(/pqs9000/images/point.png)',
                                    width: 16,
                                    height: 16
                                },
                                "data": zj,
                                "events": {
                                    cursor: 'pointer',
                                    onclick: function (e) {
                                        var eventIndex = data[26][e.point.index];
                                        layer
                                            .open({
                                                type: 2,
                                                title: '波形分析',
                                                maxmin: false,
                                                shadeClose: true, // 点击遮罩关闭层
                                                area: ['100%', '100%'],
                                                content: 'vdwaveform?eventIndex='
                                                    + eventIndex,
                                                scrollbar: false
                                            });
                                    }
                                }
                            });
                            colo.push(red)
                        }
                    }
                }
            } else {
                if (targetName == "相电压有效值" || targetName == "三相电压不平衡度" || targetName == "电压不平衡" || targetName == "三相总有功功率" || targetName == "三相总无功功率" || targetName == "三相总视在功率") {

                } else {
                    if ((number + 1) == 1) {
                        zj = data[22];
                        tmpSeries_Data.push({
                            "type": "scatter",
                            "name": "暂降触发点",
                            "marker": {
                                symbol: 'url(/pqs9000/images/point.png)',
                                width: 16,
                                height: 16
                            },
                            "data": zj,
                            "events": {
                                cursor: 'pointer',
                                click: function (e) {
                                    var eventIndex = data[21][e.point.index];
                                    layer
                                        .open({
                                            type: 2,
                                            title: '波形分析',
                                            maxmin: false,
                                            shadeClose: true, // 点击遮罩关闭层
                                            area: ['100%', '100%'],
                                            content: 'vdwaveform?eventIndex='
                                                + eventIndex,
                                            scrollbar: false
                                        });
                                }
                            }
                        });
                        colo.push(red)
                    } else if (number + 1 == 2) {
                        zj = data[25];
                        tmpSeries_Data.push({
                            "type": "scatter",
                            "name": "暂降触发点",
                            "marker": {
                                symbol: 'url(/pqs9000/images/point.png)',
                                width: 16,
                                height: 16
                            },
                            "data": zj,
                            "events": {
                                cursor: 'pointer',
                                onclick: function (e) {
                                    var eventIndex = data[24][e.point.index];
                                    layer
                                        .open({
                                            type: 2,
                                            title: '波形分析',
                                            maxmin: false,
                                            shadeClose: true, // 点击遮罩关闭层
                                            area: ['100%', '100%'],
                                            content: 'vdwaveform?eventIndex='
                                                + eventIndex,
                                            scrollbar: false
                                        });
                                }
                            }
                        });
                        colo.push(red)
                    } else {
                        zj = data[27];
                        tmpSeries_Data.push({
                            "type": "scatter",
                            "name": "暂降触发点",
                            "marker": {
                                symbol: 'url(/pqs9000/images/point.png)',
                                width: 16,
                                height: 16
                            },
                            "data": zj,
                            "events": {
                                cursor: 'pointer',
                                onclick: function (e) {
                                    var eventIndex = data[26][e.point.index];
                                    layer
                                        .open({
                                            type: 2,
                                            title: '波形分析',
                                            maxmin: false,
                                            shadeClose: true, // 点击遮罩关闭层
                                            area: ['100%', '100%'],
                                            content: 'vdwaveform?eventIndex='
                                                + eventIndex,
                                            scrollbar: false
                                        });
                                }
                            }
                        });
                        colo.push(red)
                    }
                }
            }
        }
        series_Data[number] = (tmpSeries_Data);
        series_Nav[number] = (tmpSeries_Nav);
    }

}

/*******************************************************************************
 * 10、更新图形
 ******************************************************************************/
function updateCharts() {
    if (path.indexOf("his") != -1) {
        var name = splitName(num);// 所选择的监测点
    } else {
        var name = window.parent.document.getElementById("lineName").value;

    }
    var targetName;// 所选择指标名称
    var targetId = obj_Search.condition.split(",");
    // 单监测点多指标情况
    if (targetId.length >= 1 && pointNum == 1) {
        for (var i = 0; i < targetId.length; i++) {
            targetName = getTargetName(targetId[i]);// 获取指标名称
            var data = obj_History[i];
            updateWaveData(targetName, i, data);
        }
    }
    // 多监测点单指标情况
    else if (targetId.length == 1 && pointNum > 1) {
        targetName = getTargetName(targetId);// 获取指标名称
        for (var i = 0; i < pointNum; i++) {
            var data = obj_History[i];
            updateWaveData(targetName, i, data);
        }
    }
    // //分割查询控制
    // controlSplitSearch();
}

/*******************************************************************************
 * 11、查询控制
 ******************************************************************************/
function controlSplitSearch() {
    // 更新完图形之后需要重新进行查询
    if (xhcs <= realxhcs - 1) {
        // 假如是最后一次查询，则结束时间为选择时间
        if (xhcs == realxhcs - 1) {
//            obj_Search.startTime = dataAddOneDay(obj_Search.endTime);
        	obj_Search.startTime = obj_Search.endTime;
            obj_Search.endTime = obj_Search.endAllTime;
        } else if (xhcs < realxhcs - 1) {
//            obj_Search.startTime = dataAddOneDay(obj_Search.endTime);
        	obj_Search.startTime = obj_Search.endTime;
            obj_Search.endTime = dateAddDays(obj_Search.startTime, xhday);
        }

        var aoData = new Array();// 所有查询条件a
        aoData.push(obj_Search);
        obj_Search.dataType = 1 //0,默认 在线 1，离线
        getData(aoData);
        // alert("进行了查询次数：" + xhcs);
    }
}

/*******************************************************************************
 * 更新图表
 *
 * @param targetName
 *            所选择的目标名称
 * @param data
 *            传入数据
 ******************************************************************************/
function updateWaveData(targetName, number, data) {
    var chart = $('#container' + (number + 1)).highcharts();
    // chart.series[0].setData(data);
    // chart.navigator.series[0].setData(data)
    var subdata = parseInt(obj_Search.valueType);// 取值下标
    if (data == undefined) {
        // chart.navigator.series[0].setData(null);
    } else {
        if (chart == undefined) {
            pushWaveData(targetName, data, number);
            ityzl_CLOSE_LOAD_LAYER(loading);// 关闭loading
        } else {
            if (targetName == "频率" || targetName == "三相电压不平衡度") {
                if (targetName == "三相电压不平衡度") {
                    if (chart.navigator.series[0] != null) {
                        chart.navigator.series[0].setData([]);
                        chart.navigator.series[0].setData(data[subdata]);
                    }
                    if (chart.series[0] != null) {
                        chart.series[0].setData([]);
                        chart.series[0].setData(data[subdata]);
                    }
                    if (chart.series[1] != null) {
                        chart.series[1].setData([]);
                        chart.series[1].setData(data[15]);
                    }
                } else {
                    if (chart.navigator.series[0] != null) {
                        chart.navigator.series[0].setData([]);
                        chart.navigator.series[0].setData(data[subdata]);
                    }
                    if (chart.series[0] != null) {
                        chart.series[0].setData([]);
                        chart.series[0].setData(data[subdata]);
                    }
                    if (chart.series[1] != null) {
                        chart.series[1].setData([]);
                        chart.series[1].setData(data[13]);
                    }
                    if (chart.series[2] != null) {
                        chart.series[2].setData([]);
                        chart.series[2].setData(data[12]);
                    }
                }
            } else if (targetName == "三相总有功功率" || targetName == "三相总无功功率" || targetName == "三相总视在功率") {
                if (chart.navigator.series[0] != null) {
                    chart.navigator.series[0].setData([]);
                    chart.navigator.series[0].setData(data[subdata]);
                }
                if (chart.series[0] != null) {
                    chart.series[0].setData([]);
                    chart.series[0].setData(data[subdata]);
                }
            } else if (targetName == "电压总谐波畸变率") {
                if (data[28] == 2) {
                    if (chart.navigator.series[0] != null) {
                        chart.navigator.series[0].setData([]);
                        chart.navigator.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.navigator.series[1] != null) {
                        chart.navigator.series[1].setData([]);
                        chart.navigator.series[1].setData(data[subdata + 4]);
                    }

                    if (chart.series[0] != null) {
                        chart.series[0].setData([]);
                        chart.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.series[1] != null) {
                        chart.series[1].setData([]);
                        chart.series[1].setData(data[subdata + 4]);
                    }
                    if (chart.series[2] != null) {
                        chart.series[2].setData([]);
                        chart.series[2].setData(data[14]);
                    }
                } else {
                    if (chart.navigator.series[0] != null) {
                        chart.navigator.series[0].setData([]);
                        chart.navigator.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.navigator.series[1] != null) {
                        chart.navigator.series[1].setData([]);
                        chart.navigator.series[1].setData(data[subdata + 4]);
                    }
                    if (chart.navigator.series[2] != null) {
                        chart.navigator.series[2].setData([]);
                        chart.navigator.series[2].setData(data[subdata + 8]);
                    }

                    if (chart.series[0] != null) {
                        chart.series[0].setData([]);
                        chart.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.series[1] != null) {
                        chart.series[1].setData([]);
                        chart.series[1].setData(data[subdata + 4]);
                    }
                    if (chart.series[2] != null) {
                        chart.series[2].setData([]);
                        chart.series[2].setData(data[subdata + 8]);
                    }
                    if (chart.series[3] != null) {
                        chart.series[3].setData([]);
                        chart.series[3].setData(data[14]);
                    }
                }
            } else if (targetName == "电压偏差") {
                if (data[28] == 2) {
                    if (chart.navigator.series[0] != null) {
                        chart.navigator.series[0].setData([]);
                        chart.navigator.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.navigator.series[1] != null) {
                        chart.navigator.series[1].setData([]);
                        chart.navigator.series[1].setData(data[subdata + 4]);
                    }

                    if (chart.series[0] != null) {
                        chart.series[0].setData([]);
                        chart.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.series[1] != null) {
                        chart.series[1].setData([]);
                        chart.series[1].setData(data[subdata + 4]);
                    }
                    if (chart.series[2] != null) {
                        chart.series[2].setData([]);
                        chart.series[2].setData(data[17]);
                    }
                    if (chart.series[3] != null) {
                        chart.series[3].setData(data[16]);
                    }
                } else {
                    if (chart.navigator.series[0] != null) {
                        chart.navigator.series[0].setData([]);
                        chart.navigator.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.navigator.series[1] != null) {
                        chart.navigator.series[1].setData([]);
                        chart.navigator.series[1].setData(data[subdata + 4]);
                    }
                    if (chart.navigator.series[2] != null) {
                        chart.navigator.series[2].setData([]);
                        chart.navigator.series[2].setData(data[subdata + 8]);
                    }

                    if (chart.series[0] != null) {
                        chart.series[0].setData([]);
                        chart.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.series[1] != null) {
                        chart.series[1].setData([]);
                        chart.series[1].setData(data[subdata + 4]);
                    }
                    if (chart.series[2] != null) {
                        chart.series[2].setData([]);
                        chart.series[2].setData(data[subdata + 8]);
                    }
                    if (chart.series[3] != null) {
                        chart.series[3].setData([]);
                        chart.series[3].setData(data[17]);
                    }
                    if (chart.series[4] != null) {
                        chart.series[4].setData(data[16]);
                    }
                }
            } else if (targetName == "长时电压闪变") {
                if (data[28] == 2) {
                    if (chart.navigator.series[0] != null) {
                        chart.navigator.series[0].setData([]);
                        chart.navigator.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.navigator.series[1] != null) {
                        chart.navigator.series[1].setData([]);
                        chart.navigator.series[1].setData(data[subdata + 4]);
                    }

                    if (chart.series[0] != null) {
                        chart.series[0].setData([]);
                        chart.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.series[1] != null) {
                        chart.series[1].setData([]);
                        chart.series[1].setData(data[subdata + 4]);
                    }
                    if (chart.series[2] != null) {
                        chart.series[2].setData([]);
                        chart.series[2].setData(data[18]);
                    }
                } else {
                    if (chart.navigator.series[0] != null) {
                        chart.navigator.series[0].setData([]);
                        chart.navigator.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.navigator.series[1] != null) {
                        chart.navigator.series[1].setData([]);
                        chart.navigator.series[1].setData(data[subdata + 4]);
                    }
                    if (chart.navigator.series[2] != null) {
                        chart.navigator.series[2].setData([]);
                        chart.navigator.series[2].setData(data[subdata + 8]);
                    }

                    if (chart.series[0] != null) {
                        chart.series[0].setData([]);
                        chart.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.series[1] != null) {
                        chart.series[1].setData([]);
                        chart.series[1].setData(data[subdata + 4]);
                    }
                    if (chart.series[2] != null) {
                        chart.series[2].setData([]);
                        chart.series[2].setData(data[subdata + 8]);
                    }
                    if (chart.series[3] != null) {
                        chart.series[3].setData([]);
                        chart.series[3].setData(data[18]);
                    }
                }
            } else if (targetName == "短时电压闪变") {
                if (data[28] == 2) {
                    if (chart.navigator.series[0] != null) {
                        chart.navigator.series[0].setData([]);
                        chart.navigator.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.navigator.series[1] != null) {
                        chart.navigator.series[1].setData([]);
                        chart.navigator.series[1].setData(data[subdata + 4]);
                    }

                    if (chart.series[0] != null) {
                        chart.series[0].setData([]);
                        chart.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.series[1] != null) {
                        chart.series[1].setData([]);
                        chart.series[1].setData(data[subdata + 4]);
                    }
                } else {
                    if (chart.navigator.series[0] != null) {
                        chart.navigator.series[0].setData([]);
                        chart.navigator.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.navigator.series[1] != null) {
                        chart.navigator.series[1].setData([]);
                        chart.navigator.series[1].setData(data[subdata + 4]);
                    }
                    if (chart.navigator.series[2] != null) {
                        chart.navigator.series[2].setData([]);
                        chart.navigator.series[2].setData(data[subdata + 8]);
                    }

                    if (chart.series[0] != null) {
                        chart.series[0].setData([]);
                        chart.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.series[1] != null) {
                        chart.series[1].setData([]);
                        chart.series[1].setData(data[subdata + 4]);
                    }
                    if (chart.series[2] != null) {
                        chart.series[2].setData([]);
                        chart.series[2].setData(data[subdata + 8]);
                    }
                }
            } else if (targetName == "谐波电压含有率") {
                if (data[28] == 2) {
                    if (chart.navigator.series[0] != null) {
                        //chart.navigator.series[0].remove(true);
                        chart.navigator.series[0].setData([]);
                        chart.navigator.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.navigator.series[1] != null) {
                        //chart.navigator.series[1].remove(true);
                        chart.navigator.series[1].setData([]);
                        chart.navigator.series[1].setData(data[subdata + 4]);
                    }
                    if (chart.series[0] != null) {
                        //chart.series[0].remove(true);
                        chart.series[0].setData([]);
                        chart.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.series[1] != null) {
                        //chart.series[1].remove(true);
                        chart.series[1].setData([]);
                        chart.series[1].setData(data[subdata + 4]);
                    }
                    if (parseInt(obj_Search.harmonic) > 1
                        && parseInt(obj_Search.harmonic) < 26) {
                        if (chart.series[2] != null) {
                            chart.series[2].setData([]);
                            chart.series[2].setData(data[19]);
                        }
                    }
                } else {
                    if (chart.navigator.series[0] != null) {
                        //chart.navigator.series[0].remove(true);
                        chart.navigator.series[0].setData([]);
                        chart.navigator.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.navigator.series[1] != null) {
                        //chart.navigator.series[1].remove(true);
                        chart.navigator.series[1].setData([]);
                        chart.navigator.series[1].setData(data[subdata + 4]);
                    }
                    if (chart.navigator.series[2] != null) {
                        //chart.navigator.series[2].remove(true);
                        chart.navigator.series[2].setData([]);
                        chart.navigator.series[2].setData(data[subdata + 8]);
                    }
                    if (chart.series[0] != null) {
                        //chart.series[0].remove(true);
                        chart.series[0].setData([]);
                        chart.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.series[1] != null) {
                        //chart.series[1].remove(true);
                        chart.series[1].setData([]);
                        chart.series[1].setData(data[subdata + 4]);
                    }
                    if (chart.series[2] != null) {
                        //chart.series[2].remove(true);
                        chart.series[2].setData([]);
                        chart.series[2].setData(data[subdata + 8]);
                    }
                    if (parseInt(obj_Search.harmonic) > 1
                        && parseInt(obj_Search.harmonic) < 26) {
                        if (chart.series[3] != null) {
                            chart.series[3].setData([]);
                            chart.series[3].setData(data[19]);
                        }
                    }
                }
            } else if (targetName == "谐波电流幅值") {
                if (chart.navigator.series[0] != null) {
                    chart.navigator.series[0].setData([]);
                    chart.navigator.series[0].setData(data[subdata + 0]);
                }
                if (chart.navigator.series[1] != null) {
                    chart.navigator.series[1].setData([]);
                    chart.navigator.series[1].setData(data[subdata + 4]);
                }
                if (chart.navigator.series[2] != null) {
                    chart.navigator.series[2].setData([]);
                    chart.navigator.series[2].setData(data[subdata + 8]);
                }

                if (chart.series[0] != null) {
                    chart.series[0].setData([]);
                    chart.series[0].setData(data[subdata + 0]);
                }
                if (chart.series[1] != null) {
                    chart.series[1].setData([]);
                    chart.series[1].setData(data[subdata + 4]);
                }
                if (chart.series[2] != null) {
                    chart.series[2].setData([]);
                    chart.series[2].setData(data[subdata + 8]);
                }
                if (parseInt(obj_Search.harmonic) > 1
                    && parseInt(obj_Search.harmonic) < 26) {
                    if (chart.series[3] != null) {
                        chart.series[3].setData(data[20]);
                    }
                }
            } else if (targetName == "线电压有效值" || targetName == "电压波动") {
                if (data[28] == 2) {
                    if (chart.navigator.series[0] != null) {
                        chart.navigator.series[0].setData([]);
                        chart.navigator.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.navigator.series[1] != null) {
                        chart.navigator.series[1].setData([]);
                        chart.navigator.series[1].setData(data[subdata + 4]);
                    }

                    if (chart.series[0] != null) {
                        chart.series[0].setData([]);
                        chart.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.series[1] != null) {
                        chart.series[1].setData([]);
                        chart.series[1].setData(data[subdata + 4]);
                    }
                } else {
                    if (chart.navigator.series[0] != null) {
                        chart.navigator.series[0].setData([]);
                        chart.navigator.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.navigator.series[1] != null) {
                        chart.navigator.series[1].setData([]);
                        chart.navigator.series[1].setData(data[subdata + 4]);
                    }
                    if (chart.navigator.series[2] != null) {
                        chart.navigator.series[2].setData([]);
                        chart.navigator.series[2].setData(data[subdata + 8]);
                    }

                    if (chart.series[0] != null) {
                        chart.series[0].setData([]);
                        chart.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.series[1] != null) {
                        chart.series[1].setData([]);
                        chart.series[1].setData(data[subdata + 4]);
                    }
                    if (chart.series[2] != null) {
                        chart.series[2].setData([]);
                        chart.series[2].setData(data[subdata + 8]);
                    }
                }
            } else {
                if (chart.navigator.series[0] != null) {
                    chart.navigator.series[0].setData([]);
                    chart.navigator.series[0].setData(data[subdata + 0]);
                }
                if (chart.navigator.series[1] != null) {
                    chart.navigator.series[1].setData([]);
                    chart.navigator.series[1].setData(data[subdata + 4]);
                }
                if (chart.navigator.series[2] != null) {
                    chart.navigator.series[2].setData([]);
                    chart.navigator.series[2].setData(data[subdata + 8]);
                }

                if (chart.series[0] != null) {
                    chart.series[0].setData([]);
                    chart.series[0].setData(data[subdata + 0]);
                }
                if (chart.series[1] != null) {
                    chart.series[1].setData([]);
                    chart.series[1].setData(data[subdata + 4]);
                }
                if (chart.series[2] != null) {
                    chart.series[2].setData([]);
                    chart.series[2].setData(data[subdata + 8]);
                }
            }
            chart.redraw(true);
        }
    }

}

/*******************************************************************************
 * 单位指标名称
 ******************************************************************************/
function getTargetName(targetid) {
    var targetName;
    if (targetid == 11) {
        targetName = "相电压有效值"; // 相电压有效值
    } else if (targetid == 12) {
        targetName = "线电压有效值"; // 线电压有效值
    } else if (targetid == 13) {
        targetName = "电压偏差"; // 电压偏差
    } else if (targetid == 15) {
        targetName = "三相电压不平衡度"; // 三相电压不平衡度
    } else if (targetid == 16) {
        targetName = "电压不平衡度"; // 电压不平衡度
    } else if (targetid == 17) {
        targetName = "电压总谐波畸变率"; // 电压总谐波畸变率
    } else if (targetid == 21) {
        targetName = "电流有效值"; // 电流有效值
    } else if (targetid == 22) {
        targetName = "电流总谐波畸变率"; // 电流总谐波畸变率
    } else if (targetid == 31) {
        targetName = "频率"; // 频率
    } else if (targetid == 41) {
        targetName = "谐波电压含有率"; // 谐波电压含有率(N次谐波)
    } else if (targetid == 42) {
        targetName = "谐波电流幅值"; // 谐波电流幅值
    } else if (targetid == 51) {
        targetName = "三相有功功率"; // 三相有功功率
    } else if (targetid == 52) {
        targetName = "三相无功功率"; // 三相无功功率
    } else if (targetid == 53) {
        targetName = "三相视在功率"; // 三相视在功率
    } else if (targetid == 54) {
        targetName = "三相总有功功率"; // 三相有功功率
    } else if (targetid == 55) {
        targetName = "三相总无功功率"; // 三相无功功率
    } else if (targetid == 56) {
        targetName = "三相总视在功率"; // 三相视在功率
    } else if (targetid == 61) {
        targetName = "短时电压闪变"; // 短时电压闪变
    } else if (targetid == 62) {
        targetName = "长时电压闪变"; // 长时电压闪变
    } else if (targetid == 63) {
        targetName = "电压波动"; // 电压波动
    }
    return targetName;
}

/*******************************************************************************
 * 单位获取
 ******************************************************************************/
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 == "三相有功功率" || targetName == "三相总有功功率") {
        unit = 'kW'; // 单位为kW
    } else if (targetName == "三相无功功率" || targetName == "三相总无功功率") {
        unit = 'kVar'; // 单位为kVar
    } else if (targetName == "三相视在功率" || targetName == "三相总视在功率") {
        unit = 'kVA'; // 单位为kVA
    } else if (targetName == "电压不平衡度") {
        unit = '';
    }
    return unit;
}

function changeTree(ptType) {
    var numd = splitTree(num);
    getPttype(numd)
    var zTree = $.fn.zTree.getZTreeObj("target");
    zTree.checkAllNodes(false);
    disabledNode(false);
    if (ismult) {
        if(path.indexOf("his") != -1){
        	parent.triggerCheckBox(1);
        }
        num = 2;
        if (isType) {
            var node = zTree.getNodeByParam("id", 11);
            zTree.checkNode(node, true, true);
        } else {
            var node = zTree.getNodeByParam("id", 12);
            zTree.checkNode(node, true, true);
        }
    } else {
        num = 1;
        if(path.indexOf("his") != -1){
	        parent.triggerCheckBox(2);
	        parent.setTreeSelected(2, 1)
        }
        if (isType) {
            for (var i = 0; i < 3; i++) {
                var node = zTree.getNodeByParam("id", 11 + i);
                zTree.checkNode(node, true, true);
            }
        } else {
            for (var i = 0; i < 2; i++) {
                var node = zTree.getNodeByParam("id", 12 + i);
                zTree.checkNode(node, true, true);
            }
            var node = zTree.getNodeByParam("id", 17);
            zTree.checkNode(node, true, true);
        }
    }
    nodes = [];
    checkTarget();
}
