Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

120
Vistas
How to log the callbacks (object) for Chart.js tooltips? (v3.0)

I'm trying to make custom tooltips for Chart.js (v3.0), however, when I console.log the context of the function it says:

TypeError: Converting circular structure to JSON

Is there a way to log this, so I can see the available data??

Code Example:

            plugins: {
                legend: {
                    display: false
                },
                maintainAspectRatio: false,
                responsive: true,
                tooltip: {
                    callbacks: {
                        label: function(context) {
                            let label = new Intl.NumberFormat('en-US', {style: 'percent', minimumFractionDigits: 0, maximumFractionDigits: 0}).format(context.parsed.y);
                            return label;
                        },
                        title: function(context) {
                            console.log("the context: "+JSON.stringify(context))
                            let title = context[0].label;
                            return title;
                        }
                    },
                    displayColors: false
                }
            }

Any help is appreciated.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Instead of stringifying the context just pass the variable and print that in the console, this way it's way more usable since it contains a lot of info so you can click through it without it being a big mess.

If you really want to print it as a string you can look at this answer: How can I print a circular structure in a JSON-like format?

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda