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

136
Views
Can you add an action to an element within the tooltip in chart.js?

I have a line chart drawn with chart.js that shows some data. I've added a delete element within the tooltip, but I don't know if it's possible to add an interaction, so that when I click the delete element, within the tooltip, some custom code is run that deletes the data from the Data base.

const weight_graphOptions = {
  title: {
    text: 'Weight',
    display: true
  },
  scales: {
    x: {
      type: 'time',
      time: {
        // Luxon format string
        tooltipFormat: 'dd-MM-yyyy'
      },
      title: {
        display: true,
        text: 'Date'
      }
    },
    y: {
      title: {
        display: true,
        text: 'kg'
      }
    }
  },
  plugins: {
    tooltip: {
      events: ['click'],
      callbacks: {
        afterFooter:
          function (addDeleteButton) {
            return 'Delete'
          }
      }
    }
  }
}

Does anyone know if I can do this without building my own custom-made tooltip?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No this is not possible with the default provided tooltip, first it won't stay so when you try to hover the tooltip it's not there anymore Second reason it won't work is because chart.js does not have any event listeners that listen to clicks/hovers over specific parts of the tooltip or the tooltip in general.

So you will need to make a custom external html tooltip that stays even while you don't hover datapoint anymore where you can add a normal button

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!