import { streetLightGC, colors } from '../../highcharts/main';

export function C3_makeLinecol(title, measure,acum , sections, dataReal, dataPpto, dataPptoMensual, dataPptoAnual){

    var acumPoint = sections.length-1;
    var dataRealAcum = acum;
    // var dataRealAcum = Math.round(dataRealAcum);

    var minReal = Math.min.apply(Math, dataReal);
    var maxReal = Math.max.apply(Math, dataReal);
    var minPpto = Math.min.apply(Math, dataPpto);
    var maxPpto = Math.max.apply(Math, dataPpto);

    var arrMin = [minReal, minPpto];
    var arrMax = [maxReal, maxPpto]; 
    var minKpis = Math.min.apply(Math, arrMin);
    var maxKpis = Math.max.apply(Math, arrMax);

    var auxMin = -2000000;
    var auxMax = 2000000;

    var chart = {
      chart: {
        height: 350,
        zoomType: 'xy'
      },
      title: {
        text: title
      },
      credits: {
        enabled: false
      },
      legend: {
        borderWidth: 2,
        borderRadius: 3
      },
      tooltip: {
        shared: true,
        enabled: true,
        // crosshairs: true
      },
      xAxis: {
        categories: sections
      },
      yAxis: [{
        title: { text: measure },
        // min: auxMin,
        // max: auxMax
      }, {
        title: { text: measure },
        // min: 0,
        // max: dataPptoAnual,
        opposite: true
      }],
      series: [{
            color: colors.t,
            type: 'spline',
            name: 'Real',
            data: dataReal,
            yAxis: 0
        }, {
            color: colors.g,
            type: 'spline',
            name: 'Ppto',
            data: dataPpto,
            yAxis: 0
        }, {
            yAxis: 1,
            type: 'column',
            pointStart: acumPoint,
            color: colors.t,
            name: 'Real acumulado',
            dataLabels : {
                enabled: false
            },
            data: [ dataRealAcum ]
        },
        // {
        //     yAxis: 1,
        //     type: 'column',
        //     pointStart: acumPoint,
        //     color: streetLightGC(dataPptoMensual),
        //     name: 'Ppto. acumulado mensual',
        //     dataLabels : {
        //         enabled: false
        //     },
        //     data: [ dataPptoMensual ]
        // },
         {
            yAxis: 1,
            type: 'column',
            pointStart: acumPoint,
            color: streetLightGC(dataPptoAnual),
            name: 'Ppto. acumulado anual',
            dataLabels : {
                enabled: false
            },
            data: [ dataPptoAnual ]
        }
      ] // Fin series

    } // Fin chart

    return chart;
  }
