export class PieChart {

    constructor() {
        this.height = null;
        this.title = null;
        this.series = [];
        this.size = null;
        this.width = null;
        this.yTitle = '%';
        this.xTitle = '';
        this.subtitle = null;
        this.categories = null;
        this.yMin = 0;
        this.yMax = 100;
        this.type = 'column';
        this.export = false;
        this.drilldown = false;
        this.legend = true;
        this.stacking = null;
        this.stackLabels = false;
        this.grouping = true;
        this.metrica = '%'
        this.pointWidth = undefined;
        this.enableYaxis = true;
        this.configStackLabels = ['white', 'normal'];
        this.headerTooltip = '<span style="font-size:15px">{point.key}</span><br>';
        this.bodyTooltip = '<span class= "uk-center" style="font-size:13px"><span  class=" uk-text-bold" style="color:{point.color};">■ </span><span>{series.name}: </span>{point.y:.2f}'+ this.metrica +'</span><br>';
        this.minRange = 1;
        this.axisType = 'datetime';
    }

    setMetrica(metrica) {
        this.metrica = metrica;
    }

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

    setHeight(height) {
        this.height = height;
    };

    setWidth(width) {
        this.width = width;
    };

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

    setYMin(yMin) {
        this.yMin = yMin;
    };

    setYMax(yMax) {
        this.yMax = yMax;
    };

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

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

    setSubtitle(subtitle) {
        this.subtitle = subtitle;
    };

    setType(type) {
        this.type = type;
    };

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

    setDrilldownEvent(drilldown) {
        this.drilldown = drilldown;
    };

    setLegend(legend){
        this.legend = legend;
    };

    setStacking(stacking){
        this.stacking = stacking;
    };

    setStackLabels(labels){
        this.stackLabels = labels;
    };

    setGrouping(grouping){
        this.grouping = grouping;
    };
    
    setPointWidth(point){
        this.pointWidth = point;
    };

    setEnabledYAxis(enabled){
        this.enableYaxis = enabled;
    };

    setConfigStackLabels(enabled){
        this.configStackLabels = enabled;
    };

    setMinRange(min){
        this.minRange = min;
    };

    setAxisType(axisType){
        this.axisType = axisType;
    };

    Draw(){

        var PieDefaultChart = {

                    chart: {
                        plotBackgroundColor: null,
                        plotBorderWidth: null,
                        plotShadow: false,
                        type: 'pie',
                        height: 300
                    },
                    colors: ['#00758d','#00C1E5', '#3E5987', '#8DA5D8', '#004E5D', '#AEE3ED'],
                    title: {
                        text: '',
                        floating: true,
                    },
                    legend: {
                    align: 'right',
                    verticalAlign: 'top',
                    layout: 'vertical',
                    // maxHeight: 100
                    },
                    lang:{
                        noData: "Datos Insuficientes."
                    },
                    credits: {
                    enabled: false
                    },
                    tooltip: {
                        pointFormat: '{point.name}: <b>{point.percentage:.2f}%</b>'
                    },
                    plotOptions: {
                        pie: {
                            allowPointSelect: true,
                            cursor: 'pointer',
                            dataLabels: {
                                enabled: false
                            },
                            showInLegend: true
                        },
                        series: {
                            dataLabels: {
                                enabled: true,
                                formatter: function() {
                                    return Math.round(this.percentage*100)/100 + ' %';
                                },
                                distance: 30,
                                color:'black'
                            }
                        }
                    },
                    series: this.series
                };


    return PieDefaultChart;


    }


}
  