$(function () {
    BWA.ChartOptions = BWA.ChartOptions || {};
    var C = BWA.ChartOptions.ElecPeak = BWA.ChartOptions.ElecPeak || {};

    C.getChartOptionsMIN = function (codeTimeType, goalUpperBound, maxValue) {
        return {
            legend: {
                visible: true,
                verticalAlignment: 'top',
                horizontalAlignment: 'center',
            },

            valueAxis: {
                type: 'bar',
                pane: 'topPane',
                valueField: 'Value',
                name: '전력',
                max: maxValue,
                title: {
                    text: '전력 (kW)'
                },

                constantLines: [{
                    label: {
                        text: '목표전력'
                    },
                    width: 2,
                    value: goalUpperBound,
                    color: '#ff4500',
                    dashStyle: 'dash'
                }]
            },

            series: {
                type: 'bar',
                pane: 'topPane',
                valueField: 'Value',
                name: '전력',
            },

            argumentAxis:
            {
                argumentType: 'datetime',
                label: {
                    alignment: 'center',
                    format: 'dd일 HH시-mm분'
                },
                tickInterval: { minutes: 1 },
            },

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

            panes: [{
                name: 'topPane',
                border: {
                    visible: false,
                    left: false,
                    right: false,
                    top: false,
                    color: 'gray'
                }
            }],
            defaultPane: "topPane",
            tooltip: {
                enabled: true,
                format: 'fixedPoint',
                precision: 2,
                shared: true,
                argumentFormat: 'shortDate',
                customizeTooltip: function () {
                    //return { text: '['+this.argument.format('yyyy-MM-dd HH:mm') + '] : ' + this.value };
                    return this.valuetext;
                }
            },
            crosshair: {
                enabled: true,
                width: 2,
                horizontalLine: {
                    color: 'limegreen',
                    dashStyle: 'solid',
                    visible: false
                },
                verticalLine: {
                    color: 'limegreen',
                    dashStyle: 'solid',
                    visible: true
                },
                label: {
                    visible: true,
                    backgroundColor: "#949494",
                    font: {
                        color: "#fff",
                        size: 12,
                    }
                }
            }
        };
    };
    C.getChartOptionsDAY = function (codeTimeType, goalUpperBound, maxValue, MS, ME) {
        return {
            legend: {
                visible: true,
                verticalAlignment: 'top',
                horizontalAlignment: 'center',
            },
            //adjustOnZoom: true,
            valueAxis: {
                type: 'bar',
                pane: 'topPane',
                valueField: 'Value',
                name: '전력',
                max: maxValue,
                title: {
                    text: '전력 (kW)'
                },

                constantLines: [{
                    label: {
                        text: '목표전력'
                    },
                    width: 2,
                    value: goalUpperBound,
                    color: '#ff4500',
                    dashStyle: 'dash'
                }]
            },

            series: {
                type: 'bar',
                pane: 'topPane',
                valueField: 'Value',
                name: '전력',
            },
            argumentAxis:
            {
                argumentType: 'MaxDateTime',
                label: {
                    alignment: 'center',
                    format: 'MM월 dd일'
                },
                tickInterval: { days: 1 },
                //maxValueMargin: 0.01,
                min: moment(MS).add(1, 'days').toDate(),
                max: moment(ME).add(-1, 'days').toDate()
            },

            commonSeriesSettings: {
                argumentField: "DateTime",
                selectionStyle: {
                    hatching: {
                        direction: "right"
                    }
                },
                equalColumnWidth: true
            },

            panes: [{
                name: 'topPane',
                border: {
                    visible: false,
                    left: false,
                    right: false,
                    top: false,
                    color: 'gray'
                }
            }],
            defaultPane: "topPane",
            tooltip: {
                enabled: true,
                format: 'fixedPoint',
                precision: 2,
                shared: true,
                argumentFormat: 'shortDate',
                customizeTooltip: function () {
                    // return { text: '[' + this.argument.format('yyyy-MM-dd HH:mm') + '] : ' + this.value };
                    return this.valuetext;
                }
            },
            crosshair: {
                enabled: true,
                width: 2,
                horizontalLine: {
                    color: 'limegreen',
                    dashStyle: 'solid',
                    visible: false
                },
                verticalLine: {
                    color: 'limegreen',
                    dashStyle: 'solid',
                    visible: false
                },
                label: {
                    visible: true,
                    backgroundColor: "#949494",
                    font: {
                        color: "#fff",
                        size: 12,
                    }
                }
            }
        };
    };
    C.getChartOptionsMONTH = function (codeTimeType, goalUpperBound, maxValue, MS, ME) {
        return {
            legend: {
                visible: true,
                verticalAlignment: 'top',
                horizontalAlignment: 'center',
            },
            //adjustOnZoom: true,
            valueAxis: {
                type: 'bar',
                pane: 'topPane',
                valueField: 'Value',
                name: '전력',
                max: maxValue,
                title: {
                    text: '전력 (kW)'
                },

                constantLines: [{
                    label: {
                        text: '목표전력'
                    },
                    width: 2,
                    value: goalUpperBound,
                    color: '#ff4500',
                    dashStyle: 'dash'
                }]
            },

            series: {
                type: 'bar',
                pane: 'topPane',
                valueField: 'Value',
                name: '전력',
            },

            argumentAxis:
            {
                argumentType: 'MaxDateTime',
                label: {
                    alignment: 'center',
                    format: 'MM월'
                },
                tickInterval: { months: 1 },
                //maxValueMargin: 0.01,
                min: moment(MS).add(1, 'months').toDate(),
                max: moment(ME).add(-1, 'months').toDate()
            },

            commonSeriesSettings: {
                argumentField: "DateTime",
                selectionStyle: {
                    hatching: {
                        direction: "right"
                    }
                },
                equalColumnWidth: true
            },

            panes: [{
                name: 'topPane',
                border: {
                    visible: false,
                    left: false,
                    right: false,
                    top: false,
                    color: 'gray'
                }
            }],
            defaultPane: "topPane",
            tooltip: {
                enabled: true,
                format: 'fixedPoint',
                precision: 2,
                shared: true,
                argumentFormat: 'shortDate',
                customizeTooltip: function () {
                    //return { text: '[' + this.argument.format('yyyy-MM-dd HH:mm') + '] : ' + this.value };
                    return this.valuetext;
                },
            },
            crosshair: {
                enabled: true,
                width: 2,
                horizontalLine: {
                    color: 'limegreen',
                    dashStyle: 'solid',
                    visible: false
                },
                verticalLine: {
                    color: 'limegreen',
                    dashStyle: 'solid',
                    visible: false
                },
                label: {
                    visible: false,
                    backgroundColor: "#949494",
                    font: {
                        color: "#fff",
                        size: 12,
                    }
                }
            }
        };
    };
});