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

143
Views
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 answers
Answer question

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 Report

0

In Chartjs, it has getElementsAtEventForMode not eventsForMode.. use

Chart.getElementsAtEventForMode

instead of

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