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

144
Vistas
console error when using getElementsAtEventForMode

I'm trying to call the function getElementsAtEventForMode() in my chart.js doughnut chart, but i keep getting this error message in console: chart.getElementsAtEventsForMode is not a function.

       // Pass the canvas ID
        let myChart = Chart.getChart('myChart');

        //updating chart with new values each time a value is selected
        if (myChart) {
            myChart.data.labels = legend;
            myChart.data.datasets[0].data = stats;
            myChart.config.options.plugins.title.text = "Top 5 causes of death in " + country;
            myChart.update();
        } else {
            new Chart('myChart', config);
        }

        //detecting click on doughnut sections for modal
        this.clickHandler = function (onclick) {
            const points = myChart.getElementsAtEventForMode(onclick, 'nearest', { intersect: true }, true);

            if (points[0]) {
                modal.classList.toggle('hide');
            }
        }

        addEventListener("click", this.clickHandler);
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You can't use the global chart instance, you need to use your chart instance to call the function like so:

const chartInstance = Chart.getChart(canvasId);

const points = chartInstance.getElementsAtEventForMode("click", 'nearest', { intersect: true }, true);
about 4 years ago · Juan Pablo Isaza Denunciar

0

In Chartjs, it has getElementsAtEventForMode not eventsForMode.. use

Chart.getElementsAtEventForMode

instead of

Chart.getElementsAtEventsForMode
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