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

311
Visualizações
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
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