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

    var valueAxises = [{
        pane: 'topPane',
        name: 'R',
        position: 'right',
        title: {
            text: '가동시간'
        }
    }
    ];

    var fuelTypeValueAxises = [{
        pane: 'topPane',
        title: {
            text: $G('electricityConsumptionUsageWithUnit')
        }
    }, {
        pane: 'topPane',
        title: {
            text: $G('gasUsageWithUnit')
        }
    }, {
        pane: 'topPane',
        title: {
            text: $G('waterUsageWithUnit')
        }
    }];

    var series = [{
        type: 'bar',
        pane: 'topPane',
        axis: 'R',
        valueField: 'R_Value',
        visible: true, // 시리즈만 안보이게 할수 있다. 대신 그렇게 할려면 시작은 false로 해야 한다 hcLee 2015 04 25
        point: { size: 8 },
        name: '냉동기 가동시간',
        label: {
            visible: false,
            customizeText: function () {
                return this.valueText + '분';
            }
        }
    },
{
    type: 'bar',
    pane: 'topPane',
    axis: 'R',
    valueField: 'B_Value',
    visible: true, // 시리즈만 안보이게 할수 있다. 대신 그렇게 할려면 시작은 false로 해야 한다 hcLee 2015 04 25
    point: { size: 8 },
    name: '보일러 가동시간',
    label: {
        visible: false,
        customizeText: function () {
            return this.valueText + '분';
        }
    }
}
    ];

    var fuelTypeSeries = [{
        type: 'line',
        pane: 'topPane',
        valueField: 'Value',
        name: $G('elec'),
        label: {
            horizontalAlignment: 'left',
            visible: false,
            customizeText: function () {
                return this.valueText + 'kWh';
            }
        }
    }, {
        type: 'line',
        pane: 'topPane',
        valueField: 'Value',
        name: $G('gas'),
        label: {
            visible: false,
            customizeText: function () {
                return this.valueText + 'm3';
            }
        }
    }, {
        type: 'line',
        pane: 'topPane',
        valueField: 'Value',
        name: $G('water'),
        label: {
            visible: false,
            customizeText: function () {
                return this.valueText + 'm3';
            }
        }
    }];

    C.getSeriesOptions = function (codeTimeType, fuelTypeId, goalUpperBound) {
        return {

            valueAxis: [$.extend({}, fuelTypeValueAxises[fuelTypeId - 1], {
                showZero: true,
            })].concat(valueAxises),
            series: [fuelTypeSeries[fuelTypeId - 1]].concat(series),
        };
    };

    C.getChartOptions = function (codeTimeType, goalUpperBound) {
        return {
            legend: {
                visible: true,
                verticalAlignment: 'top',
                horizontalAlignment: 'center'
            },
            commonSeriesSettings: {
                argumentField: "DateTime",
                selectionStyle: {
                    hatching: {
                        direction: "left"
                    }
                }
            },

            panes: [{
                name: 'topPane',
                border: {
                    visible: false,
                    left: false,
                    right: false,
                    top: false,
                    color: 'gray'
                }
            }, ],
            defaultPane: "topPane",
            tooltip: {
                format: 'fixedPoint',
                precision: 2,

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