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

222
Visualizações
How can I disable the Highstocks range selector buttons when loading data asynchronously?

I'm creating a chart similar to the Highcharts lazy loading example where I'm retrieving data from my backend service every time the user zooms in via mouse drag or interaction with the navigator. Clicking on the range selector buttons works correctly as well, but the issue I'm running into is that the buttons are not disabled while my chart is loading - since it takes awhile for the data to load due to the nature of my backend, this means that users can click on the other buttons as many times as they want.

This leads to multiple calls to the backend which ultimately messes up how the chart is displayed. For example, I can click on the "1y" option then "1d". Since the "1y" view takes much longer to load, the graph will first display the "1d" data and then switch to the "1y" one later. Even though it switches, the "1d" button will still appear as the one selected last.

In addition to the Highcharts/Highstocks API documentation, I've looked at plenty of posts on StackOverflow as well as GitHub but there doesn't seem to be any answer to this problem. I've tried changing the "chartOptions" variable like so:

rangeSelector.enabled = false;

but this causes the entire graph to re-render each time, which also resets my navigator view. I've also tried the useRef hook to see if a request has already been made, and to not create a new one if so, but clicking on the range selector buttons still changes the chart view even though it doesn't explicitly send a call to the backend. The last solution I can think of creating a div that I use to essentially "block out" the range selector buttons while loading, but that seems like a pretty hack-y fix. Is there anything else I should try? Thanks!

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

0

While fetching the data, set a loading variable as true and when the data is fetched, set loading to false. Then set a prop disabled={!loading}.

about 4 years ago · Juan Pablo Isaza Relatório

0

The simplest way will be to toggle by CSS only rangeSelector group:

  chart.rangeSelector.group.css({
    display: 'none'
  });

Live example: https://jsfiddle.net/BlackLabel/g906s4k2/

API Reference: https://api.highcharts.com/class-reference/Highcharts.SVGElement#css

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