$(function() {
    BWA.ChartOptions = BWA.ChartOptions || {};
    BWA.ChartOptions.WaterCoolingAnalysis = BWA.ChartOptions.WaterCoolingAnalysis || {};

    var valueAxises = [{
        name: 'in_temp',
        position: 'right',
        //valueMarginsEnabled: true,
        //minValueMargin: 0,
        //maxValueMargin: 0,
        label: {
            font: { color: '#c96374' },
            visible: true,
            //format: 'largeNumber'
        },

        title: {
            text: '코일 입/출구 온도'
        }
    }
    /*, {
        name: 'out_temp',
        //min: 0,
        //max: 100,
        position: 'right',
        grid: {
            visible: true
        },
        label: {
            font: { color: '#00A7C6' },
            visible: true,
            //format: 'largeNumber'
        },
        title: {
            text: '온수코일 출구온도'
        }
    }*/]; // 4개의 온도값은 하나온도의 축으로 통일 2015 06 15

    var seriesSHot = [{
        type: 'spline',
        color: '#c96374',
        axis: 'in_temp',
        valueField: 'in_temp',
        point: { size: 2 },
        name: '온수코일 입구온도',
        label: {
            visible: false,
            font: { color: '#c96374', },
            customizeText: function () {
                return this.valueText + ' °C';
            }
        }
    }, {
        type: 'spline',
        axis: 'in_temp',
        color: '#00A7C6',
        valueField: 'out_temp',
        point: { size: 2 },
        name: '온수코일 출구온도',
        label: {
            font: { color: '#00A7C6', },
            visible: false,
            customizeText: function () {
                return this.valueText + ' °C';
            }
        }
    }];

    var seriesSCold = [{
        type: 'spline',
        color: '#c963FF',
        axis: 'in_temp',
        valueField: 'cold_in_temp',
        point: { size: 2 },
        name: '냉수코일 입구온도',
        label: {
            visible: false,
            font: { color: '#c963FF', },
            customizeText: function () {
                return this.valueText + ' °C';
            }
        }
    }, {
        type: 'spline',
        axis: 'in_temp',
        color: '#00A7FF',
        valueField: 'cold_out_temp',
        point: { size: 2 },
        name: '냉수코일 출구온도',
        label: {
            font: { color: '#00A7FF', },
            visible: false,
            customizeText: function () {
                return this.valueText + ' °C';
            }
        }
    }];

    BWA.ChartOptions.WaterCoolingAnalysis.getChartCalorieCOptions = function(codeTimeType) {
        return {
            palette: "Bright",
            legend: {
                visible: true,
                verticalAlignment: 'top',
                horizontalAlignment: 'center'
            },

            //argumentAxis: BWA.Chart.getTimeLineArgumentAxis(null, codeTimeType),
            // ㅎㅎ 이게 있어야 멀티드로잉이 된다. 2015 04 21
            commonSeriesSettings: {
                argumentField: "DateTime",
                selectionStyle: {
                    hatching: {
                        direction: "left"
                    }
                }
            },

            valueAxis: [{
                name: 'water',
                position: 'left',
                title: {
                    text: $G('WaterUnit')
                }
            }].concat(valueAxises),

            series: [{
                axis: 'water',
                type: 'bar',
                name: '냉수유량',
                argumentField: "DateTime",
                valueField: 'CV', // 
                label: {
                    visible: false,
                },
                point: { size: 8 }
            }].concat(seriesSCold),

            tooltip: {
                enabled: true,
            },

            crosshair: {
                enabled: true,
                width: 2,
                horizontalLine: {
                    color: 'red',
                    dashStyle: 'dash',
                    visible: false
                },
                verticalLine: {
                    color: 'black',
                    dashStyle: 'dash',
                    visible: true
                },
                label: {
                    visible: true,
                    backgroundColor: "#949494",
                    font: {
                        color: "#fff",
                        size: 12,
                    }
                }
            }

        };

    };
    BWA.ChartOptions.WaterCoolingAnalysis.getChartCalorieHOptions = function (codeTimeType) {
        return {
            palette: "Harmony Light",
            legend: {
                visible: true,
                verticalAlignment: 'top',
                horizontalAlignment: 'center'
            },

            //argumentAxis: BWA.Chart.getTimeLineArgumentAxis(null, codeTimeType),
            // ㅎㅎ 이게 있어야 멀티드로잉이 된다. 2015 04 21
            commonSeriesSettings: {
                argumentField: "DateTime",
                selectionStyle: {
                    hatching: {
                        direction: "left"
                    }
                }
            },

            valueAxis: [{
                name: 'water',
                position: 'left',
                title: {
                    text: $G('WaterUnit')
                }
            }].concat(valueAxises),

            series: [{
                axis: 'water',
                type: 'bar',
                name: '온수유량',
                argumentField: "DateTime",
                valueField: 'HV', // 냉수
                label: {
                    visible: false,
                },
                point: { size: 8 }
            }, ].concat(seriesSHot),

            tooltip: {
                enabled: true,
            },

            crosshair: {
                enabled: true,
                width: 2,
                horizontalLine: {
                    color: 'red',
                    dashStyle: 'dash',
                    visible: false
                },
                verticalLine: {
                    color: 'black',
                    dashStyle: 'dash',
                    visible: true
                },
                label: {
                    visible: true,
                    backgroundColor: "#949494",
                    font: {
                        color: "#fff",
                        size: 12,
                    }
                }
            }

        };

    };

    var valueAxise_1 = {
        name: 'AFw',
        position: 'right',
        label: {
            visible: true,
        },

        title: {
            text: '냉방 ATF'
        }
    }

    var series_1 = {
        type: 'spline',
        color: '#c96374',
        axis: 'AFw',
        valueField: 'afw',
        point: { size: 4 },
        name: '냉방 ATF',
        label: {
            visible: false,
            //font: { color: '#c96374', },
            customizeText: function () {
                return '냉방 ATF';
            }
        }
    }

    BWA.ChartOptions.WaterCoolingAnalysis.getChart_1_Options = function (codeTimeType) {
        return {
            palette: "Bright",
            legend: {
                visible: true,
                verticalAlignment: 'top',
                horizontalAlignment: 'center'

            },

            commonSeriesSettings: {
                argumentField: "DateTime",
                selectionStyle: {
                    hatching: {
                        direction: "left"
                    }
                }
            },

            valueAxis: [{
                title: {
                    text: '냉수열량 (kcal)'
                }
            }].concat(valueAxise_1),

            series: [{
                type: 'bar',
                valueField: 'kcal',
                argumentField: 'DateTime',
                name: '냉수열량',
                label: {
                    visible: false,
                    //customizeText: function() {
                    //    return this.argumentField + this.valueText;
                    //}
                },
                point: { size: 8 }
            }].concat(series_1),

            tooltip: {
                enabled: true,
                format: 'fixedPoint',
                precision: 2,

            },

            crosshair: {
                enabled: true,
                width: 2,
                horizontalLine: {
                    color: 'red',
                    dashStyle: 'dash',
                    visible: false
                },
                verticalLine: {
                    color: 'black',
                    dashStyle: 'dash',
                    visible: true
                },
                label: {
                    visible: true,
                    backgroundColor: "#949494",
                    font: {
                        color: "#fff",
                        size: 12,
                    }
                }
            }

        };
    };

    var valueAxise_2 = {
        name: 'AFw',
        position: 'right',
        label: {
            visible: true,
        },

        title: {
            text: '난방 ATF'
        }
    }

    var series_2 = {
        type: 'spline',
        color: '#c96374',
        axis: 'AFw',
        valueField: 'afw',
        point: { size: 4 },
        name: '난방 ATF',
        label: {
            visible: false,
            //font: { color: '#c96374', },
            customizeText: function () {
                return '난방 ATF';
            }
        }
    }

    BWA.ChartOptions.WaterCoolingAnalysis.getChart_2_Options = function (codeTimeType) {
        return {
            palette: "Default",
            legend: {
                visible: true,
                verticalAlignment: 'top',
                horizontalAlignment: 'center'

            },

            commonSeriesSettings: {
                argumentField: "DateTime",
                selectionStyle: {
                    hatching: {
                        direction: "left"
                    }
                }
            },

            valueAxis: [{
                title: {
                    text: '온수열량 (kcal)'
                }
            }].concat(valueAxise_2),

            series: [{
                type: 'bar',
                valueField: 'kcal',
                argumentField: 'DateTime',
                name: '온수열량',
                label: {
                    visible: false,
                    //customizeText: function() {
                    //    return this.argumentField + this.valueText;
                    //}
                },
                point: { size: 8 }
            }].concat(series_2),

            tooltip: {
                enabled: true,
            },

            crosshair: {
                enabled: true,
                width: 2,
                horizontalLine: {
                    color: 'red',
                    dashStyle: 'dash',
                    visible: false
                },
                verticalLine: {
                    color: 'black',
                    dashStyle: 'dash',
                    visible: true
                },
                label: {
                    visible: true,
                    backgroundColor: "#949494",
                    font: {
                        color: "#fff",
                        size: 12,
                    }
                }
            }

        };
    };

    BWA.ChartOptions.WaterCoolingAnalysis.getChart_3_Options = function (codeTimeType) {
        return {
            palette: "Bright",
            legend: {
                visible: true,
                verticalAlignment: 'top',
                horizontalAlignment: 'center'
            },

            commonSeriesSettings: {
                argumentField: "DateTime",
                selectionStyle: {
                    hatching: {
                        direction: "left"
                    }
                }
            },

            valueAxis: [
            {
                title: {
                    text: '소비전력량 (kWh)'
                }
            },
            {
                name: 'hz',
                position: 'right',
                label: {
                    visible: true,
                },
                title: {
                    text: '주파수 (Hz)'
                }
            }
            ],

            series: [
            {
                type: 'bar',
                valueField: 'inkw',
                argumentField: 'DateTime',
                name: '급기팬 소비전력',
                label: {
                    visible: false,
                    //customizeText: function() {
                    //    return this.argumentField + this.valueText;
                    //}
                },
                point: { size: 4 }
            },
            {
                type: 'bar',
                valueField: 'outkw',
                argumentField: 'DateTime',
                name: '환기팬 소비전력',
                label: {
                    visible: false,
                    //customizeText: function() {
                    //    return this.argumentField + this.valueText;
                    //}
                },
                point: { size: 4 }
            },
            {
                type: 'spline',
                axis: 'hz',
                valueField: 'inhz',
                argumentField: 'DateTime',
                name: '급기팬 주파수',
                label: {
                    visible: false,
                    //customizeText: function() {
                    //    return this.argumentField + this.valueText;
                    //}
                },
                point: { size: 4 }
            },
            {
                type: 'spline',
                axis: 'hz',
                valueField: 'outhz',
                argumentField: 'DateTime',
                name: '환기팬 주파수',
                label: {
                    visible: false,
                    //customizeText: function() {
                    //    return this.argumentField + this.valueText;
                    //}
                },
                point: { size: 4 }
            },

            ],

            tooltip: {
                enabled: true,
            },

            crosshair: {
                enabled: true,
                width: 2,
                horizontalLine: {
                    color: 'red',
                    dashStyle: 'dash',
                    visible: false
                },
                verticalLine: {
                    color: 'black',
                    dashStyle: 'dash',
                    visible: true
                },
                label: {
                    visible: true,
                    backgroundColor: "#949494",
                    font: {
                        color: "#fff",
                        size: 12,
                    }
                }
            }

        };
    };
});