import { Globals } from "../../app/app.globals";
export class FailureModeChart {



    constructor(){

        this.chart = null;
        this.container = null;
        this.title = '';
        this.yTitle = 'Horas';
        this.metricId = 0;
        this.metricSize = 0;
        this.series = [];
        this.categories=[];

    }

    setSeries(series) {
        this.series = series;
    };


    setTitle(title) {
        this.title = title;
    };

    setCategories(categories) {
        this.categories = categories;
    };

    setYTitle(yTitle){
        this.yTitle = yTitle;
    };

    setExport(exporting) {
        this.export = exporting;
    };

    Draw(){

        var failureMode = {
            // colors: ['#198EA6', '#0a3842', '#badde4', '#DDDF00', '#24CBE5', '#64E572', 
            //  '#FF9655', '#FFF263', '#6AF9C4'],
            // colors: ['#00758d','#dc272d','#f6a800','#5ecbca','#8a8a8e'],
            colors: ['#285367',
            '#5ADED4',
            '#32758c',
            '#26596A',
            '#163342',
            '#6C98A1'],
            chart: {
                type: 'column',
                // height: 450,
                zoomType: 'x'
                /*scrollablePlotArea: {
                    minWidth: 10000,
                    scrollPositionX: 1
            },*/
            },
            lang: {
                noData: "Datos Insuficientes."
            },
            title: {
                text: this.title,
                x: -20 //center
            },
            subtitle: {
                text: '', //'Reliability & Maintenance Engineering System',
                x: -20
            },
            credits: {
                enabled:false
            },
            xAxis: {
                title: {
                    text:null,
                },
                categories: this.categories,
                labels: {
                    // rotation: -60, // para que el texto del eje se vea ladeado
                    formatter: function() {
                        return this.value;
                    }
                },
                min: 0,
                  max: (this.categories.length-1>10 ? 10 : this.categories.length-1),
                  /*scrollbar: {
                    enabled: true
                  },*/
            },
            yAxis: [
                {
                    title: {
                        text: this.yTitle
                    },
                    /*labels: {
                        formatter: function() {
                            return this.value;
                        }
                    }*/
    
                     stackLabels: {
                            enabled: true,
                            style: {
                                fontWeight: 'bold',
                                color:'black'
                            }
                         }
                }
                // ,
                // {
                //     title: {text: ''},
                //     max: 100,
                //     min: 0,
                //     lineColor: '#333',
                //     opposite: true,
                //     labels: {
                //         formatter: function() {
                //             return this.value + '%';
                //         }
                //     }
                // }
    
            ],
            legend: {
                //layout: 'vertical',
                enabled: false,
                borderWidth: 0,
                maxHeight: 60
            },
            tooltip: {
                pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y:.' + Globals.CANTDECIMALES +'f}</b><br/>',
                shared: true,
                zIndex: 99999,
                useHTML: true
            },
            plotOptions: {
                column: {
                    borderWidth: 0,
                },
                spline: {
                    marker: {
                        enable: false
                    }
                },
                series: {
                    stacking: 'normal'
                }
            },
            series: this.series
        };
        
        return failureMode;

    }



	
}
