var path = window.location.href;// 获取界面路径

// init method one
var obj_Search = parent.objSearch;
var height = $("body").height();
$(document).ready(function () {

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

var harmonic = parent.objSearch.harmonic;
/*******************************************************************************
 * 5、分段查询控制 xhday:分割时间（默认3天） 情况1：假如时间差小于分割时间，则一次查找好 情况2：假如时间差大于分割时间，则分批次查询
 ******************************************************************************/
var spitDays = 0;// 所选时间差：天
var xhcs = 0;// 分割查询次数，默认是0次表示不需要进行查询
var realxhcs = 0;// 实际需要循环次数
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 = 0 //0,默认 在线 1，离线
    aoData.push(obj_Search);
    getData(aoData);
    getLimitRate(aoData);
}

function CheckDateTime() {
    var result = true;// 默认时间是负荷的
    var startTime = obj_Search.startTime;//parent.$("#startTime").val();// 起始时间
    var endTime = obj_Search.endTime;//parent.$("#endTime").val();// 结束时间

    if (!compareTime(startTime, endTime)) {
        layer.msg("时间设置错误,开始时间大于结束时间!");
        result = false;
    }
    if (obj_Search != null) {
        obj_Search.startAllTime = startTime;// 总起始时间
        obj_Search.endAllTime = endTime;// 总结束时间
        obj_Search.startTime = startTime;
        obj_Search.endTime = endTime;
    }
    return result;
}

/*******************************************************************************
 * 查询和数据展示 1、获取监测点和指标信息 2、判断查询时间是否合理 3、定义界面的布局 4、控制界面是否显示
 ******************************************************************************/
function queryAndShowData() {
    // 实例化参数，确保每次查询重置
    InstantiationParameter();
    if (CheckDateTime()) {
        spitTime();
    }

}


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

/*******************************************************************************
 * 6、数据查询 *** aoData **** 所有查询条件
 ******************************************************************************/
function getData(aoData) {
    $.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) {
                drawCharts();
                isData();
                /***************************************************************
                 * 循环次数跟时间2间隔一样，则表示该所选的时间段小于时间间隔 则需要判断是否有数据，以及停止滚动条
                 **************************************************************/
                // todo
            } else if (xhcs == 1 && realxhcs > 0) {
                drawCharts();
                if (obj_History.length > 0) {
                    ityzl_CLOSE_LOAD_LAYER(loading);// 关闭loading
                } else if (realxhcs == 1) {
                    isData();
                }
                //updateCharts();
                // controlSearch(false);

                /***************************************************************
                 * 循环次数跟时间2间隔一样，则表示该所选的时间段小于时间间隔 则需要判断是否有数据，以及停止滚动条
                 **************************************************************/
                // todo
            } else if (xhcs < (realxhcs)) {
                ityzl_CLOSE_LOAD_LAYER(loading);// 关闭loading
                // controlSearch(false);
                drawCharts();
                updateCharts();
            } else if (xhcs == realxhcs) {
                // 更新图形
                drawCharts();
                isData();
                updateCharts();
            }
        }
    })
}

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;
}

/*******************************************************************************
 * 8、解析数据 *** data **** 返回数据
 ******************************************************************************/
// 暂降触发点最小值,对比所有的最小值，取ABC三项最小值
function analysisData(data) {
    var tmpData;// 根据图
    // 数据解析
    for (var m = 0; m < obj_Search.historynum; m++) {
        // 定义obj存储数据
        var tmpObj_Data = [];
        // 数据源获取定义
        switch (m) {
            case 0:
                tmpData = data.data1;
                break;
            case 1:
                tmpData = data.data2;
                break;
            case 2:
                tmpData = data.data3;
                break;
        }
        // 开始解析数据

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

        if (tmpData.length > 0) {
            if (tmpData[0][0] == 15 || tmpData[0][0] == 31) {
                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])]);

                    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)]]);
                        }
                    }
                }
                // 临时数据赋值
                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;// 三相电压不平衡度
                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);
                    obj_History[m] = tmpObj_History;// 重新给该位置赋值
                }
                // 假如为空则执行插入
                else {
                    obj_History.push(tmpObj_Data);
                }
            } else {
                // 数据解析
                for (var i = 0; i < tmpData.length; i++) {

                    if (tmpData[0][0] == 61 || tmpData[0][0] == 62
                        || tmpData[0][0] == 63) {
                        tmpTime = parseFloat(tmpData[i][1]);
                        // 平均值
                        avr.push([tmpTime, parseFloat(tmpData[i][2])]);
                        bvr.push([tmpTime, parseFloat(tmpData[i][3])]);
                        cvr.push([tmpTime, parseFloat(tmpData[i][4])]);
                        if (tmpObj_Limit != null) {
                            flicker.push([tmpTime, tmpObj_Limit.flicker]);
                            SfreqDev.push([tmpTime, tmpObj_Limit.SfreqDev]);
                            XfreqDev.push([tmpTime, tmpObj_Limit.XfreqDev]);
                            uaberrance
                                .push([tmpTime, tmpObj_Limit.uaberrance]);
                            ubalance.push([tmpTime, tmpObj_Limit.ubalance]);
                            SvoltageDev.push([tmpTime,
                                tmpObj_Limit.SvoltageDev]);
                            XvoltageDev.push([tmpTime,
                                tmpObj_Limit.XvoltageDev]);
                            if (parseInt(harmonic) > 1
                                && parseInt(harmonic) < 26) {
                                uharm
                                    .push([
                                        tmpTime,
                                        tmpObj_Limit.uharm[parseInt(harmonic) - 2]]);
                                iharm
                                    .push([
                                        tmpTime,
                                        tmpObj_Limit.iharm[parseInt(harmonic) - 2]]);
                            }
                        }
                    } else {
                        tmpTime = parseFloat(tmpData[i][1]);
                        // 平均值
                        avr.push([tmpTime, parseFloat(tmpData[i][2])]);
                        bvr.push([tmpTime, parseFloat(tmpData[i][3])]);
                        cvr.push([tmpTime, parseFloat(tmpData[i][4])]);
                        // 最小值
                        amin.push([tmpTime, parseFloat(tmpData[i][5])]);
                        bmin.push([tmpTime, parseFloat(tmpData[i][6])]);
                        cmin.push([tmpTime, parseFloat(tmpData[i][7])]);

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

/*******************************************************************************
 * 9、新增图形
 ******************************************************************************/
function drawCharts() {
    objdata = [];
    $('#container').html("");
    if (obj_History.length > 0) {
        var name = obj_Search.lineName;
        var targetName;// 所选择指标名称
        var targetId = obj_Search.condition;
        // 单监测点多指标情况

        targetName = getTargetName(targetId);// 获取指标名称
        objdata = obj_History[0];
        pushWaveData(targetName, objdata);
        initWave(name, targetName, 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, data) {
    var index1 = [];
    var zj = [], getZj = [], zmin = [];
    var unit = getUnit(targetName);// 获取展示Y单位
    $("#container").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', {
        title: {
            text: name + " " + targetName
        },
        subtitle: {
            text: titleName,
            style: {
                color: "#ff0000"
            }
        },
        dataLabels: {
            allowOverlap: true
        },
        tooltip: {
            borderColor: grey,
            backgroundColor: 'rgba(105,105,105,0.7)',
            style: {
                color: 'white',
                fontSize: "15px",
                padding: 10,
            },
            formatter: function () {
                var s = '<b>时刻：'
                    + Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x)
                    + '</b>';
                $.each(this.points, function () {
                    if (this.series.name == "零序电压(V)") {
                        s += '<br/>' + this.series.name + ': '
                            + this.y.toFixed(4) + 'V';
                    } else if (this.series.name == "正序电压(kV)") {
                        s += '<br/>' + this.series.name + ': '
                            + this.y.toFixed(4) + 'kV';
                    } else if (this.series.name == "负序电压(V)") {
                        s += '<br/>' + this.series.name + ': '
                            + this.y.toFixed(4) + 'V';
                    } else {
                        s += '<br/>' + this.series.name + ': '
                            + this.y.toFixed(4) + unit;
                    }
                });
                return s;
            },
            shared: true
        },
        // 导航器各项属性设置
        navigator: {
            height: 20,
            margin: 1,
            xAxis: {
                labels: {
                    formatter: function () {
                        return Highcharts.dateFormat('%Y-%m-%d %H:%M:%S',
                            this.value);
                    }
                }
            },
            series: series_Nav[0]
        },
        rangeSelector: {
            enabled: false
        },
        scrollbar: {
            enabled: false
        },
        credits: false,
        colors: colo,
        xAxis: {
            title: {
                text: '(时间)',
                enabled: true,
                align: 'high',
            },
            labels: {
                step: 2
            },
            type: 'datetime',
            dateTimeLabelFormats: {
                second: '%H:%M:%S',
                minute: '%H:%M',
                hour: '%H:%M',
                day: '%m-%d',
                week: '%m-%d',
                month: '%Y-%m',
                year: '%Y'
            },
        },
        yAxis: {
            title: {
                align: 'high',
                offset: 0,
                text: unit,
                rotation: 0,
                y: -10
            },
            opposite: false
        },
        legend: {
            align: 'left',
            verticalAlign: 'top',
            enabled: true
        },
        series: series_Data[0]
    });
    $('.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.length == 0) {
            layer.msg("没有获取到该监测点的历史数据", {
                icon: 5,
                time: 3000
            });
            container.style.display = "none";
            point.style.display = "block";
        }
        ityzl_CLOSE_LOAD_LAYER(loading);// 关闭loading
    } else if (realxhcs == 0) {
        if (obj_History.length == 0) {
            layer.msg("没有获取到该监测点的历史数据", {
                icon: 5,
                time: 3000
            });
            container.style.display = "none";
            point.style.display = "block";
        }
        ityzl_CLOSE_LOAD_LAYER(loading);// 关闭loading
    } else {
        if (obj_History.length == 0) {
            container.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.type);// 取值下标
    if (data == null) {
        if (series_Data.length < 3) {
            series_Data.push(tmpSeries_Data);
            series_Nav.push(tmpSeries_Nav);
        }
    } else {
        if (targetName == "频率" || targetName == "三相电压不平衡度") {
            if (targetName == "三相电压不平衡度") {
                tmpSeries_Nav.push({
                    "data": data[subdata]
                });
                tmpSeries_Data.push({
                    "name": "三相电压不平衡度",
                    "data": data[subdata]
                });
                tmpSeries_Data.push({
                    "dashStyle": "shortdash",
                    "name": "上限(" + data[15][0][1] + ")",
                    "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[13][0][1] + ")",
                    "data": data[13]
                });
                tmpSeries_Data.push({
                    "dashStyle": "shortdash",
                    "name": "下限(" + data[12][0][1] + ")",
                    "data": data[12]
                });
                colo.push(yellow, red, red)
            }
        } else if (targetName == "电压总谐波畸变率") {
            if (obj_Search.phase == 'AB' || obj_Search.phase == 'A') {
                tmpSeries_Nav.push({
                    "data": data[subdata + 0]
                });
                tmpSeries_Data.push({
                    "name": obj_Search.phase + "相",
                    "data": data[subdata]
                });
                tmpSeries_Data.push({
                    "dashStyle": "shortdash",
                    "name": "上限(" + data[14][0][1] + ")",
                    "data": data[14]
                });

                colo.push(yellow, red);
            } else if (obj_Search.phase == 'B' || obj_Search.phase == 'BC') {
                tmpSeries_Nav.push({
                    "data": data[subdata + 4]
                });
                tmpSeries_Data.push({
                    "name": obj_Search.phase + "相",
                    "data": data[subdata + 4]
                });
                tmpSeries_Data.push({
                    "dashStyle": "shortdash",
                    "name": "上限(" + data[14][0][1] + ")",
                    "data": data[14]
                });
                colo.push(green, red);
            } else if (obj_Search.phase == 'C' || obj_Search.phase == 'CA') {
                tmpSeries_Nav.push({
                    "data": data[subdata + 8]
                });
                tmpSeries_Data.push({
                    "name": obj_Search.phase + "相",
                    "data": data[subdata + 8]
                });
                tmpSeries_Data.push({
                    "dashStyle": "shortdash",
                    "name": "上限(" + data[14][0][1] + ")",
                    "data": data[14]
                });
                colo.push(red, red);
            }
        } else if (targetName == "电压偏差") {
            titleName = null;
            if (obj_Search.phase == 'A' || obj_Search.phase == 'AB') {
                tmpSeries_Nav.push({
                    "data": data[subdata + 0]
                });
                tmpSeries_Data.push({
                    "name": obj_Search.phase + "相",
                    "data": data[subdata]
                });
                tmpSeries_Data.push({
                    "dashStyle": "shortdash",
                    "name": "上限(" + data[17][0][1] + ")",
                    "data": data[17]
                });
                tmpSeries_Data.push({
                    "dashStyle": "shortdash",
                    "name": "下限(" + data[16][0][1] + ")",
                    "data": data[16]
                });
                colo.push(yellow, red, red);
            } else if (obj_Search.phase == 'B' || obj_Search.phase == 'BC') {
                tmpSeries_Nav.push({
                    "data": data[subdata + 4]
                });
                tmpSeries_Data.push({
                    "name": obj_Search.phase + "相",
                    "data": data[subdata + 4]
                });
                tmpSeries_Data.push({
                    "dashStyle": "shortdash",
                    "name": "上限(" + data[17][0][1] + ")",
                    "data": data[17]
                });
                tmpSeries_Data.push({
                    "dashStyle": "shortdash",
                    "name": "下限(" + data[16][0][1] + ")",
                    "data": data[16]
                });
                colo.push(green, red, red);
            } else if (obj_Search.phase == 'C' || obj_Search.phase == 'CA') {
                tmpSeries_Nav.push({
                    "data": data[subdata + 8]
                });
                tmpSeries_Data.push({
                    "name": obj_Search.phase + "相",
                    "data": data[subdata + 8]
                });
                tmpSeries_Data.push({
                    "dashStyle": "shortdash",
                    "name": "上限(" + data[17][0][1] + ")",
                    "data": data[17]
                });
                tmpSeries_Data.push({
                    "dashStyle": "shortdash",
                    "name": "下限(" + data[16][0][1] + ")",
                    "data": data[16]
                });
                colo.push(red, red, red);
            }
        } else if (targetName == "长时电压闪变") {
            titleName = "该指标只有平均值";
            if (obj_Search.phase == 'A' || obj_Search.phase == 'AB') {
                tmpSeries_Nav.push({
                    "data": data[0],
                    "step": "middle"
                });
                tmpSeries_Data.push({
                    "name": obj_Search.phase + "相",
                    "data": data[0],
                    "step": "middle"
                });
                tmpSeries_Data.push({
                    "dashStyle": "shortdash",
                    "name": "上限(" + data[18][0][1] + ")",
                    "data": data[18]

                });
                colo.push(yellow, red);
            } else if (obj_Search.phase == 'B' || obj_Search.phase == 'BC') {
                tmpSeries_Nav.push({
                    "data": data[4],
                    "step": "middle"
                });
                tmpSeries_Data.push({
                    "name": obj_Search.phase + "相",
                    "data": data[4],
                    "step": "middle"
                });
                tmpSeries_Data.push({
                    "dashStyle": "shortdash",
                    "name": "上限(" + data[18][0][1] + ")",
                    "data": data[18]

                });
                colo.push(green, red);
            } else if (obj_Search.phase == 'C' || obj_Search.phase == 'CA') {
                tmpSeries_Nav.push({
                    "data": data[8],
                    "step": "middle"
                });
                tmpSeries_Data.push({
                    "name": obj_Search.phase + "相",
                    "data": data[8],
                    "step": "middle"
                });
                tmpSeries_Data.push({
                    "dashStyle": "shortdash",
                    "name": "上限(" + data[18][0][1] + ")",
                    "data": data[18]

                });
                colo.push(red, red);
            }
        } else if (targetName == "短时电压闪变" || targetName == "电压波动") {
            titleName = "该指标只有平均值";
            if (obj_Search.phase == 'A' || obj_Search.phase == 'AB') {
                tmpSeries_Nav.push({
                    "data": data[0],
                    "step": "middle"
                });
                tmpSeries_Data.push({
                    "name": obj_Search.phase + "相",
                    "data": data[0],
                    "step": "middle"
                });
                colo.push(yellow);
            } else if (obj_Search.phase == 'B' || obj_Search.phase == 'BC') {
                tmpSeries_Nav.push({
                    "data": data[4],
                    "step": "middle"
                });
                tmpSeries_Data.push({
                    "name": obj_Search.phase + "相",
                    "data": data[4],
                    "step": "middle"
                });
                colo.push(green);
            } else if (obj_Search.phase == 'C' || obj_Search.phase == 'CA') {
                tmpSeries_Nav.push({
                    "data": data[8],
                    "step": "middle"
                });
                tmpSeries_Data.push({
                    "name": obj_Search.phase + "相",
                    "data": data[8],
                    "step": "middle"
                });
                colo.push(red);
            }
        } else if (targetName == "线电压有效值") {
            if (obj_Search.phase == 'AB') {
                tmpSeries_Nav.push({
                    "data": data[subdata + 0]
                });
                tmpSeries_Data.push({
                    "name": "AB相",
                    "data": data[subdata + 0]
                });
                colo.push(yellow);
            } else if (obj_Search.phase == 'BC') {
                tmpSeries_Nav.push({
                    "data": data[subdata + 4]
                });
                tmpSeries_Data.push({
                    "name": "BC相",
                    "data": data[subdata + 4]
                });
                colo.push(green);
            } else if (obj_Search.phase == 'CA') {
                tmpSeries_Nav.push({
                    "data": data[subdata + 8]
                });
                tmpSeries_Data.push({
                    "name": "CA相",
                    "data": data[subdata + 8]
                });
                colo.push(red);
            }
        } else if (targetName == "电压不平衡") {
                tmpSeries_Nav.push({
                    "data": data[subdata + 0]
                });
                tmpSeries_Data.push({
                    "name": "零序电压(V)",
                    "data": data[subdata + 0]
                });
                tmpSeries_Nav.push({
                    "data": data[subdata + 4]
                });
                tmpSeries_Data.push({
                    "name": "正序电压(kV)",
                    "data": data[subdata + 4]
                });
                tmpSeries_Nav.push({
                    "data": data[subdata + 8]
                });
                tmpSeries_Data.push({
                    "name": "负序电压(V)",
                    "data": data[subdata + 8]
                });
                colo.push(yellow,green,red);
        } else if (targetName == "谐波电压含有率") {
            if (parseInt(obj_Search.harmonic) > 1
                && parseInt(obj_Search.harmonic) < 26) {
                if (obj_Search.phase == 'A' || obj_Search.phase == 'AB') {
                    tmpSeries_Nav.push({
                        "data": data[subdata + 0]
                    });
                    tmpSeries_Data.push({
                        "name": obj_Search.phase + "相",
                        "data": data[subdata]
                    });
                    tmpSeries_Data.push({
                        "dashStyle": "shortdash",
                        "name": parseInt(obj_Search.harmonic) + "次上限(" + data[19][0][1] + ")",
                        "data": data[19]
                    });
                    colo.push(yellow, red);
                } else if (obj_Search.phase == 'B' || obj_Search.phase == 'BC') {
                    tmpSeries_Nav.push({
                        "data": data[subdata + 4]
                    });
                    tmpSeries_Data.push({
                        "name": obj_Search.phase + "相",
                        "data": data[subdata + 4]
                    });
                    tmpSeries_Data.push({
                        "dashStyle": "shortdash",
                        "name": parseInt(obj_Search.harmonic) + "次上限(" + data[19][0][1] + ")",
                        "data": data[19]
                    });
                    colo.push(green, red);
                } else if (obj_Search.phase == 'C' || obj_Search.phase == 'CA') {
                    tmpSeries_Nav.push({
                        "data": data[subdata + 8]
                    });
                    tmpSeries_Data.push({
                        "name": obj_Search.phase + "相",
                        "data": data[subdata + 8]
                    });
                    tmpSeries_Data.push({
                        "dashStyle": "shortdash",
                        "name": parseInt(obj_Search.harmonic) + "次上限(" + data[19][0][1] + ")",
                        "data": data[19]
                    });
                    colo.push(red, red);
                }
            } else {
                if (obj_Search.phase == 'A' || obj_Search.phase == 'AB') {
                    tmpSeries_Nav.push({
                        "data": data[subdata + 0]
                    });
                    tmpSeries_Data.push({
                        "name": obj_Search.phase + "相",
                        "data": data[subdata]
                    });
                    colo.push(yellow);
                } else if (obj_Search.phase == 'B' || obj_Search.phase == 'BC') {
                    tmpSeries_Nav.push({
                        "data": data[subdata + 4]
                    });
                    tmpSeries_Data.push({
                        "name": obj_Search.phase + "相",
                        "data": data[subdata + 4]
                    });
                    colo.push(green);
                } else if (obj_Search.phase == 'C' || obj_Search.phase == 'CA') {
                    tmpSeries_Nav.push({
                        "data": data[subdata + 8]
                    });
                    tmpSeries_Data.push({
                        "name": obj_Search.phase + "相",
                        "data": data[subdata + 8]
                    });
                    colo.push(red);
                }
            }
        } else if (targetName == "谐波电流幅值") {
            if (parseInt(obj_Search.harmonic) > 1
                && parseInt(obj_Search.harmonic) < 26) {
                if (obj_Search.phase == 'A' || obj_Search.phase == 'AB') {
                    tmpSeries_Nav.push({
                        "data": data[subdata + 0]
                    });
                    tmpSeries_Data.push({
                        "name": obj_Search.phase + "相",
                        "data": data[subdata]
                    });
                    tmpSeries_Data.push({
                        "dashStyle": "shortdash",
                        "name": parseInt(obj_Search.harmonic) + "次上限(" + data[20][0][1] + ")",
                        "data": data[20]
                    });
                    colo.push(yellow, red);
                } else if (obj_Search.phase == 'B' || obj_Search.phase == 'BC') {
                    tmpSeries_Nav.push({
                        "data": data[subdata + 4]
                    });
                    tmpSeries_Data.push({
                        "name": obj_Search.phase + "相",
                        "data": data[subdata + 4]
                    });
                    tmpSeries_Data.push({
                        "dashStyle": "shortdash",
                        "name": parseInt(obj_Search.harmonic) + "次上限(" + data[20][0][1] + ")",
                        "data": data[20]
                    });
                    colo.push(green, red);
                } else if (obj_Search.phase == 'C' || obj_Search.phase == 'CA') {
                    tmpSeries_Nav.push({
                        "data": data[subdata + 8]
                    });
                    tmpSeries_Data.push({
                        "name": obj_Search.phase + "相",
                        "data": data[subdata + 8]
                    });
                    tmpSeries_Data.push({
                        "dashStyle": "shortdash",
                        "name": parseInt(obj_Search.harmonic) + "次上限(" + data[20][0][1] + ")",
                        "data": data[20]
                    });
                    colo.push(red, red);
                }
            } else {
                if (obj_Search.phase == 'A' || obj_Search.phase == 'AB') {
                    tmpSeries_Nav.push({
                        "data": data[subdata + 0]
                    });
                    tmpSeries_Data.push({
                        "name": obj_Search.phase + "相",
                        "data": data[subdata]
                    });
                    colo.push(yellow);
                } else if (obj_Search.phase == 'B' || obj_Search.phase == 'BC') {
                    tmpSeries_Nav.push({
                        "data": data[subdata + 4]
                    });
                    tmpSeries_Data.push({
                        "name": obj_Search.phase + "相",
                        "data": data[subdata + 4]
                    });
                    colo.push(green);
                } else if (obj_Search.phase == 'C' || obj_Search.phase == 'CA') {
                    tmpSeries_Nav.push({
                        "data": data[subdata + 8]
                    });
                    tmpSeries_Data.push({
                        "name": obj_Search.phase + "相",
                        "data": data[subdata + 8]
                    });
                    colo.push(red);
                }
            }
        } else {
            if (obj_Search.phase == 'A' || obj_Search.phase == 'AB') {
                tmpSeries_Nav.push({
                    "data": data[subdata + 0]
                });
                tmpSeries_Data.push({
                    "name": obj_Search.phase + "相",
                    "data": data[subdata]
                });
                colo.push(yellow);
            } else if (obj_Search.phase == 'B' || obj_Search.phase == 'BC') {
                tmpSeries_Nav.push({
                    "data": data[subdata + 4]
                });
                tmpSeries_Data.push({
                    "name": obj_Search.phase + "相",
                    "data": data[subdata + 4]
                });
                colo.push(green);
            } else if (obj_Search.phase == 'C' || obj_Search.phase == 'CA') {
                tmpSeries_Nav.push({
                    "data": data[subdata + 8]
                });
                tmpSeries_Data.push({
                    "name": obj_Search.phase + "相",
                    "data": data[subdata + 8]
                });
                colo.push(red);
            }
        }

        series_Data[0] = (tmpSeries_Data);
        series_Nav[0] = (tmpSeries_Nav);
    }

}

/*******************************************************************************
 * 10、更新图形
 ******************************************************************************/
function updateCharts() {
    var targetId = obj_Search.condition;
    targetName = getTargetName(targetId);// 获取指标名称
    var data = obj_History[0];
    updateWaveData(targetName, data);
}


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

        var aoData = new Array();// 所有查询条件a
        obj_Search.dataType = 0 //0,默认 在线 1，离线
        aoData.push(obj_Search);
        getData(aoData);
    }
}

/*******************************************************************************
 * 更新图表
 *
 * @param targetName
 *            所选择的目标名称
 * @param data
 *            传入数据
 ******************************************************************************/
function updateWaveData(targetName, data) {
    var chart = $('#container').highcharts();
    // chart.series[0].setData(data);
    // chart.navigator.series[0].setData(data)
    var subdata = parseInt(obj_Search.type);// 取值下标
    if (targetName == "电压波动" || targetName == "短时电压闪变" || targetName == "短时电压闪变") {
        subdata = 0;
    }
    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(data[subdata]);
                    }
                    if (chart.series[0] != null) {
                        chart.series[0].setData(data[subdata]);
                    }
                } else {
                    if (chart.navigator.series[0] != null) {
                        chart.navigator.series[0].setData(data[subdata]);
                    }
                    if (chart.series[0] != null) {
                        chart.series[0].setData(data[subdata]);
                    }
                }
            } else if (targetName == "电压总谐波畸变率") {
                if (obj_Search.phase == 'A') {
                    if (chart.navigator.series[0] != null) {
                        chart.navigator.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.series[0] != null) {
                        chart.series[0].setData(data[subdata + 0]);
                    }
                } else if (obj_Search.phase == 'B') {
                    if (chart.navigator.series[1] != null) {
                        chart.navigator.series[1].setData(data[subdata + 4]);
                    }
                    if (chart.series[1] != null) {
                        chart.series[1].setData(data[subdata + 4]);
                    }
                } else if (obj_Search.phase == 'C') {
                    if (chart.navigator.series[2] != null) {
                        chart.navigator.series[2].setData(data[subdata + 8]);
                    }
                    if (chart.series[2] != null) {
                        chart.series[2].setData(data[subdata + 8]);
                    }
                }
            } else if (targetName == "电压偏差") {
                if (obj_Search.phase == 'A') {
                    if (chart.navigator.series[0] != null) {
                        chart.navigator.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.series[0] != null) {
                        chart.series[0].setData(data[subdata + 0]);
                    }
                } else if (obj_Search.phase == 'B') {
                    if (chart.navigator.series[1] != null) {
                        chart.navigator.series[1].setData(data[subdata + 4]);
                    }
                    if (chart.series[1] != null) {
                        chart.series[1].setData(data[subdata + 4]);
                    }
                } else if (obj_Search.phase == 'C') {
                    if (chart.navigator.series[2] != null) {
                        chart.navigator.series[2].setData(data[subdata + 8]);
                    }
                    if (chart.series[2] != null) {
                        chart.series[2].setData(data[subdata + 8]);
                    }
                }
            } else if (targetName == "长时电压闪变") {
                if (obj_Search.phase == 'A') {
                    if (chart.navigator.series[0] != null) {
                        chart.navigator.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.series[0] != null) {
                        chart.series[0].setData(data[subdata + 0]);
                    }
                } else if (obj_Search.phase == 'B') {
                    if (chart.navigator.series[1] != null) {
                        chart.navigator.series[1].setData(data[subdata + 4]);
                    }
                    if (chart.series[1] != null) {
                        chart.series[1].setData(data[subdata + 4]);
                    }
                } else if (obj_Search.phase == 'C') {
                    if (chart.navigator.series[2] != null) {
                        chart.navigator.series[2].setData(data[subdata + 8]);
                    }
                    if (chart.series[2] != null) {
                        chart.series[2].setData(data[subdata + 8]);
                    }
                }
            } else if (targetName == "谐波电压含有率") {
                if (obj_Search.phase == 'A') {
                    if (chart.navigator.series[0] != null) {
                        chart.navigator.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.series[0] != null) {
                        chart.series[0].setData(data[subdata + 0]);
                    }
                } else if (obj_Search.phase == 'B') {
                    if (chart.navigator.series[1] != null) {
                        chart.navigator.series[1].setData(data[subdata + 4]);
                    }
                    if (chart.series[1] != null) {
                        chart.series[1].setData(data[subdata + 4]);
                    }
                } else if (obj_Search.phase == 'C') {
                    if (chart.navigator.series[2] != null) {
                        chart.navigator.series[2].setData(data[subdata + 8]);
                    }
                    if (chart.series[2] != null) {
                        chart.series[2].setData(data[subdata + 8]);
                    }
                }
            } else if (targetName == "谐波电流幅值") {
                if (obj_Search.phase == 'A') {
                    if (chart.navigator.series[0] != null) {
                        chart.navigator.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.series[0] != null) {
                        chart.series[0].setData(data[subdata + 0]);
                    }
                } else if (obj_Search.phase == 'B') {
                    if (chart.navigator.series[1] != null) {
                        chart.navigator.series[1].setData(data[subdata + 4]);
                    }
                    if (chart.series[1] != null) {
                        chart.series[1].setData(data[subdata + 4]);
                    }
                } else if (obj_Search.phase == 'C') {
                    if (chart.navigator.series[2] != null) {
                        chart.navigator.series[2].setData(data[subdata + 8]);
                    }
                    if (chart.series[2] != null) {
                        chart.series[2].setData(data[subdata + 8]);
                    }
                }
            } else {
                if (obj_Search.phase == 'A') {
                    if (chart.navigator.series[0] != null) {
                        chart.navigator.series[0].setData(data[subdata + 0]);
                    }
                    if (chart.series[0] != null) {
                        chart.series[0].setData(data[subdata + 0]);
                    }
                } else if (obj_Search.phase == 'B') {
                    if (chart.navigator.series[1] != null) {
                        chart.navigator.series[1].setData(data[subdata + 4]);
                    }
                    if (chart.series[1] != null) {
                        chart.series[1].setData(data[subdata + 4]);
                    }
                } else if (obj_Search.phase == 'C') {
                    if (chart.navigator.series[2] != null) {
                        chart.navigator.series[2].setData(data[subdata + 8]);
                    }
                    if (chart.series[2] != null) {
                        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 == 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 == "三相有功功率") {
        unit = 'kW'; // 单位为kW
    } else if (targetName == "三相无功功率") {
        unit = 'kVar'; // 单位为kVar
    } else if (targetName == "三相视在功率") {
        unit = 'kVA'; // 单位为kVA
    } else if (targetName == "电压不平衡") {
        unit = '';
    }
    return unit;
}

function changeTree(ptType) {

}
