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

305
Views
heatmap.js Add Text Value to Heatmap Circles

I'm using heatmap.js to generate a heatmap for al the clicks on email newsletter, and the heatmap is rendering just fine. However i have an additional request in that i'd like to display the numeric value associated with each heatmap circle. I've attempted to modify the heatmap.js script to accomplish this task. The changes i've made (heatmap.js v2.0.5) are in the _drawAlpha function.

Directly below:

   shadowCtx.drawImage(tpl, rectX, rectY);

I've added the following:

   shadowCtx.font = "bold 35px sans-serif";
   shadowCtx.fillStyle = "#000000";
   shadowCtx.globalAlpha = 1;
   shadowCtx.fillText(value, rectX+55, rectY+35);

This works to some extent but the biggest issue that i'm having is actually reading the numbers. Ideally i'd like the numbers printed in black but i can't get the fillStyle to take. FYI I've also tried shadowCtx.fillStyle = "black";. I don't get any errors, it just doesn't apply the color. The only way i'm able to get any change in the font color for the values is to adjust the globalAlpha. i've tried everything from .01 to .99 and none of these are really desirable. The colors range from yellow/green/purple to redish... So currently it looks like this:

Here is what i've been able to accomplish so far

I have no problem updating the font or font-size. The values are offset to the right because if i print them in the middle of the heatmap circle the text is unreadable. Ideally the text would be black and i could print it right in the heatmap circle and it would appear above the circles.

I'm really a novice when it comes to Javascript canvas programming so any help you can provide is appreciated.

Thanks!

about 4 years ago · Juan Pablo Isaza
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!