pa7 / heatmap.js

🔥 JavaScript Library for HTML5 canvas based heatmaps
https://www.patrick-wied.at/static/heatmapjs/
MIT License
6.22k stars 1.33k forks source link

Making a transparent gradient stop #247

Closed jocooler closed 7 years ago

jocooler commented 7 years ago

Hello,

I'm trying to make a gradient that doesn't show at all until I hit a certain threshold, something like this:

"gradient": {
      0.00: "rgba(0,0,0, 0)",
          0.10: "rgba(50,200,100, 0.9)",
          0.15: "rgba(50,200,200, 0.9)",
          0.20: "rgba(0,255,0, 0.9)",
          0.24: "rgba(155,255,0, 0.9)",
          0.27: "rgba(255,255,0, 0.9)",
          0.29: "rgba(255,155,0, 0.9)",
          0.30: "rgba(255,0,0, 0.9)"
      }

But instead I get a gray color rather than transparent. I did try setting the background color to "transparent" but that didn't seem to help.

Is there a way to accomplish a truly transparent color stop?

pa7 commented 7 years ago

Hey! thanks for reaching out, there is an (unfortunately not yet documented) configuration property called useGradientAlpha https://github.com/pa7/heatmap.js/blob/master/src/renderer/canvas2d.js#L161 Could you set that to true in your heatmap configuration and try again?

jocooler commented 7 years ago

Hey, that's magic!

Thanks very much!

pa7 commented 7 years ago

glad I could help *now filing a ticket to document that property*