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

334
Visualizações
In chart.js, how do I invoke a plugin on completing the first render?

I have this plugin for chart.js that renders gradient fills for a stacked bar chart on afterRender. The gradient fills all become visible if i resize the browser window, or call chart.update() in an onClick function. The background gradient becomes visible when I hover on each individual element of the bar chart.

Calling chart.update() within that plugin forces all gradients to draw on the first render of the stacked bar chart, but seems to trigger a runaway effect where the updating of the chart triggers a re-render and that doesn't seem good.

So I'm a little puzzled on what's going wrong here. Calling chart.update() in a React hook doesn't have the expected effect for me. How do I make sure that this plugin runs and completes before the first draw? Or is there perhaps something more fundamentally wrong with this?

I am using react-chartjs-2.

Code sample: https://codesandbox.io/s/blissful-monad-vq1fn?file=/App.tsx

Appreciate any input on this

about 4 years ago · Juan Pablo Isaza
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