Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

353
Visualizações
Highcharts - Always keep hover state on single slice

This may be challenging. So my goal is to have the first largest slice always in a hover state if other slices aren't hovered. Hovered meaning other slices faded and halo on the hovered. I have added code that adds the tooltip in the middle of the doughnut chart and to shows the first slices tooltip on mouse out and load. I keep the tooltip there by using the tooltip delay trick. I am almost finished but can't figure out how to keep the halo on the slice and the other slices faded. This may have sounded confusing but hopefully these images of what I want can help.

one speed bump is that the environment that I'm putting this in wont allow me to use css or functions outside of the main highcharts function. That's why all the functions are inside.

https://jsfiddle.net/sabdorhx/1/

    events: {
  load: function() {
    var chart = this,
      legend = chart.legend,
      point = chart.series.chart;

    // starte with first slice hovered
    chart.series[0].points[0].onMouseOver();

    // Legend hover show tooltip
    for (var i = 0, len = legend.allItems.length; i < len; i++) {
      (function(i) {

        var item = legend.allItems[i].legendItem;
        item.on('mouseover', function(e) {
          //show custom tooltip here
          chart.tooltip.refresh(chart.series[0].points[i]);

        }).on('mouseout', function(e) {
          //show first slice tooltip on mouse out
          chart.tooltip.refresh(chart.series[0].points[0]);
        });
      })(i);
    }
  },
}

_

series: {
  events: {
    mouseOut: function() {
    //mouse out of slice and show first slice
      this.points[0].onMouseOver();
    },
  },

enter image description here enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The set hover state is overwritten in setState series method which is called later. In your case the function is redundant, so you can overwrite it:

Highcharts.Series.prototype.setState = function(){};

Live demo: https://jsfiddle.net/BlackLabel/z2fqre5d/

API Reference: https://api.highcharts.com/class-reference/Highcharts.Point#onMouseOver

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda