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

328
Views
How to make the whole <canvas> element in Chart.js V3.7.0 display cursor as pointer on hover?

how can I make my canvas element display cursor style as pointer when I hover over it.

HTML:

<canvas id="myChart"></canvas>

I tried both:

events: ['mousemove', 'click'],
onHover: (event, chartElement) => {
  event.target.style.cursor = chartElement[0] ? 'pointer' : 'default';
}

And:

options: {
  plugins : {
    legend: {   
      labels: {
        onHover: function (e) {
          e.native.target.style.cursor = 'pointer';
        },
        onLeave: function (e) {
          e.native.target.style.cursor = 'default';
        }
      }
    }
  }
}

But had no luck.

Pictures:

enter image description here

All in all, I want the cursor to have style equal to pointer on whole chart, and not just on the red points in the picture. (Red point with Yellow arround it, is an example of point I want my cursor to look like a pointer.).

Thanks in advance!

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

0

In CSS, you need canvas:hover{cursor: pointer}. The canvas:hover will run the code inside when the cursor is hovering over the element. The cursor: pointer will tell the cursor to become a pointer. For more information, go here for other cursor types and here for hover selector.

Or if you don't have a CSS file, you can do this: <canvas id="myChart" style="cursor: pointer"></canvas> . That will do the same thing as explained above.

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!