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

219
Views
ChartJS no puede registrar el complemento global

Después de una migración de ChartJS de v2 a v3, no puedo registrar un complemento global, siguiendo la guía de migración cambié Chart.plugins.register en Chart.register pero obtengo esto:

la clase no tiene id: función (gráfico)

Creo que el problema está en la función afterDraw, pero ¿cómo se debe solucionar después de una migración?

El código

 Chart.register({ afterDraw: function (chart) { var data = chart.data.datasets[0].data; if (data.length === 0) { // No data is present var ctx = chart.chart.ctx; var width = chart.chart.width; var height = chart.chart.height chart.clear(); ctx.save(); ctx.textAlign = 'center'; ctx.textBaseline = 'middle'; ctx.font = "16px normal 'Helvetica Nueue'"; ctx.fillText('Nessun dato disponibile', width / 2, height / 2); ctx.fontColor = "#828282"; ctx.restore(); } } });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Al leer mejor la documentación , se debe configurar una identificación única para cada complemento registrado .

Los complementos deben definir una identificación única para poder configurarse.

Así que acabo de agregar la identificación en mi código

 Chart.register({ id: 'no_data_label', afterDraw: (chart, args, options) => { const data = chart.data.datasets[0].data; if (data.length === 0) { // No data is present console.log(chart) const current = chart.ctx; const width = chart.width; const height = chart.height chart.clear(); current.save(); current.textAlign = 'center'; current.textBaseline = 'middle'; current.font = "16px normal 'Helvetica Nueue'"; current.fillText('Nessun dato disponibile', width / 2, height / 2); current.fontColor = "#828282"; current.restore(); } } });
about 4 years ago · Juan Pablo Isaza Report
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!