Hide Plot Line on Drill down Event (Highcharts.js)

2019-08-17 03:45发布

Is it possible to hide a Plot Line when I Drill down?

I have a Bar chart that Drill down to a Line Chart, in the "root" (Bar chart) I show a Plot Line Red that shows the Average value, the problem is that when I Drill down to the Line Chart, if the yAxis allow it, it is visible (the Red Plot Line), I want to hide the Plot Line on Drill down, because that average value I just need to see it in the "root" (Bar chart) not when I Drill down.

The average Plot Line has a value of 1865 and it is visible only in the year 2019, because is the only year where it reaches a value high enough to get the **yAxis** near that value

The average Plot Line has a value of 1865 and it is visible only in the year 2019, because is the only year where it reaches a value high enough to get the yAxis near that value.

So I wonder if theres a way to Hide the Plot Line when I Drill down. So I wonder if theres a way to Hide the Plot Line when I Drill down.

This is my Chart code, i fill it up with PHP, data comes from an XML.

$('#todo').highcharts({

        title: {
            text: 'Registro de IPE del año 2017 al '+<?php echo date('Y')?>
        },
        subtitle: {
            text: 'Click para ver desgloce del año.'
        },
        xAxis: {
            type: 'category'
        },
       yAxis: {
                title: {
                    text: 'Tiempo de Indisponibilidad (HORAS)'
                },
                plotLines: [{
        color: 'red',
        value: avg, // Insert your average here
        width: '1',
        zIndex: 2, // To not get stuck below the regular plot lines
        label:{text:'Promedio: '+parseInt(avg)}
    }]
            },
            credits: {
              enabled:false
            },
        legend: {
            enabled: false
        },
        plotOptions: {
            series: {
                borderWidth: 0,
                dataLabels: {
                    enabled: true,
                    format: '{point.y:.1f}'
                }
            }
        },
        lang: {
        drillUpText: '<< VOLVER'
    },

        tooltip: {
            headerFormat: '', 
            pointFormat: '<span style="color:{point.color}">{point.name}: </span> <b> {point.y}</b> Horas<br/>'
        },

        series: [{
            name: 'Brands',
            type: 'column',
            colorByPoint: true,
            data: [
            <?php
            for($i = 0; $i < $total_registros; $i++)
              {
                ?>
                {
                name: '<?php echo $registros->registro[$i]->Año; ?>',
                y: <?php list($horas, $minutos) = split('[:]', $registros->registro[$i]->TOTAL); echo $horas; ?>,
                drilldown: '<?php echo $registros->registro[$i]->Año; ?>'
                },
              <?php
            }
            ?>
            ]
        }],
        drilldown: {
          drillUpButton: {
            relativeTo: 'spacingBox',
            position: {
                y: 0,
                x: 0
            },
            theme: {
                fill: 'white',
                'stroke-width': 1,
                stroke: 'silver',
                r: 0,
                states: {
                    hover: {
                        fill: '#a4edba'
                    },
                    select: {
                        stroke: '#039',
                        fill: '#a4edba'
                    }
                }
            }

        },
          series: [
            <?php
            for($j = 0; $j < $total_registros; $j++)
              {
                ?> 
                {
                type: 'line',
                name: '<?php echo $registros->registro[$j]->Año; ?>',
                id: '<?php echo $registros->registro[$j]->Año; ?>',
                data:[
                  [
                  'Enero',
                   <?php list($horas, $minutos) = split('[:]', $registros->registro[$j]->Enero); echo $horas; ?>
                  ],
                  [
                  'Febrero',
                   <?php list($horas, $minutos) = split('[:]', $registros->registro[$j]->Febrero); echo $horas; ?>
                  ],
                  [
                  'Marzo',
                   <?php list($horas, $minutos) = split('[:]', $registros->registro[$j]->Marzo); echo $horas; ?>
                  ],
                  [
                  'Abril',
                   <?php list($horas, $minutos) = split('[:]', $registros->registro[$j]->Abril); echo $horas; ?>
                  ],
                  [
                  'Mayo',
                   <?php list($horas, $minutos) = split('[:]', $registros->registro[$j]->Mayo); echo $horas; ?>
                  ],
                  [
                  'Junio',
                   <?php list($horas, $minutos) = split('[:]', $registros->registro[$j]->Junio); echo $horas; ?>
                  ],
                  [
                  'Julio',
                   <?php list($horas, $minutos) = split('[:]', $registros->registro[$j]->Julio); echo $horas; ?>
                  ],
                  [
                  'Agosto',
                   <?php list($horas, $minutos) = split('[:]', $registros->registro[$j]->Agosto); echo $horas; ?>
                  ],
                  [
                  'Septiembre',
                   <?php list($horas, $minutos) = split('[:]', $registros->registro[$j]->Septiembre); echo $horas; ?>
                  ],
                  [
                  'Octubre',
                   <?php list($horas, $minutos) = split('[:]', $registros->registro[$j]->Octubre); echo $horas; ?>
                  ],
                  [
                  'Noviembre',
                   <?php list($horas, $minutos) = split('[:]', $registros->registro[$j]->Noviembre); echo $horas; ?>
                  ],
                  [
                  'Diciembre',
                   <?php list($horas, $minutos) = split('[:]', $registros->registro[$j]->Diciembre); echo $horas; ?>
                  ]
                ]
            },
            <?php
          }
      ?>
      ]
    }});

登录 后发表回答