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

146
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

0

In Chartjs, it has getElementsAtEventForMode not eventsForMode.. use

Chart.getElementsAtEventForMode

instead of

Chart.getElementsAtEventsForMode
about 4 years ago · Juan Pablo Isaza Relatório
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