Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

331
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!