Giter VIP home page Giter VIP logo

webgl-heatmap's Introduction

WebGL Heatmap

webgl-heatmap.js is a JavaScript library for high performance heatmap display.

Demo

Live Demo at codeflow.org

How to use it

Instantiate a new heatmap, errors can be one of:

  • Webgl is not supported
  • No floating point texture support
  • Floating point render target not supported
  • Shader Compile Error: ...
  • Shader Link Error: ...
try{
    var heatmap = createWebGLHeatmap({canvas: yourCanvas});
}
catch(error){
    // handle the error
}

creation arguments

  • canvas: the canvas you wish to draw on
  • width: explicit width
  • height: explicit height
  • intensityToAlpha: defaults to true
  • gradientTexture: texture used instead of color calculation, can be path or an image

Add a data point.

  • x and y relative to the canvas in pixels
  • size in pixels (radius)
  • intensity between 0 and 1
heatmap.addPoint(x, y, size, intensity);

Add a list of data points.

  • x and y relative to the canvas in pixels
  • size in pixels (radius)
  • intensity between 0 and 1
heatmap.addPoints([{x:x, y:y, size:size, intensity:intensity}]);

Draw queued data points:

heatmap.update()

Display the heatmap

heatmap.display()

Multiply all values in the heatmap by a number (useful for decay)

heatmap.multiply(0.995)

Clamp all values in the heatmap to between two values:

heatmap.clamp(0.0, 1.0)

Blur all values a little:

heatmap.blur()

License

Copyright (c) 2013, Florian Boesch [email protected] http://codeflow.org/

WebGL Heatmap is licensed under any of the following licenses at your choosing:

  • MIT: see mit-license
  • GPL: see gplv*-license
  • BSD: see bsd-license

webgl-heatmap's People

Contributors

jasondavies avatar pyalot avatar thijsdezoete avatar thinker0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

webgl-heatmap's Issues

preserveDrawingBuffer & getDataURL

When trying to convert the canvas to a png, I kept getting empty canvases.

This can be fixed by using getContext("experimental-webgl", {preserveDrawingBuffer: true}); when using getContext.

Just wondering whether the code should be changed accordingly.

Question

Hi @pyalot,

Thanks for the great library, i use it for a personal project.

I would like to plot a heatmap from an area which i would like to split into a grid (e.g. 100x100 meters). is that possible and how? can you overlay the heatmap on google maps somehow?

Thanks,

Specifying gradientTexture renders map colours in black

Hi,

First off thanks for creating this, it is awesome.

I was just looking to experiment with specifying my own gradient texture, however providing one of the example gradient images causes the heatmap to be rendered in black and white, not according to the colours in the image.

Downloading the current project as is and uncommenting one of the initalisation lines that specifies the gradientTexture option results in this behaviour.

Thanks in advance,
Gary

Not able to load map tile

Hi @pyalot,

I am trying to use your plugin but not able to load the map tile, I just see the datapoints.
I am running the sample code on your website. following is my code:

var baseURL = 'http://{s}.somedomain.com/blabla/{z}/{x}/{y}.png';

    var base = L.tileLayer(baseURL, {
        API: 'your-api',
        map_style: '44094'
      });

    //Halifax, Nova Scotia
    var map = L.map('map', {layers: [base]}).setView([
        44.65, -63.57
    ], 12);

    L.control.scale().addTo(map);

    //custom size for this example, and autoresize because map style has a percentage width
    var heatmap = new L.TileLayer.WebGLHeatMap({size: 500, autoresize: true});

    // dataPoints is an array of arrays: [[lat, lng, intensity]...]
    var dataPoints = [
        [
            44.6674, -63.5703, 37
        ],
        [
            44.6826, -63.7552, 34
        ],
        [
            44.6325, -63.5852, 41
        ],
        [
            44.6467, -63.4696, 67
        ],
        [
            44.6804, -63.487, 64
        ],
        [
            44.6622, -63.5364, 40
        ],
        [
            44.603, -63.743, 52
        ]
    ];

    map.addLayer(heatmap);
    heatmap.setData(dataPoints);

Interpolation increase point max value.

Hello there !

I have an accuracy issue with this awesome library.
Here is an example :
I have heatmap with blue, yellow and red colors gradient.
I want to add three points (like this example):
Point1 : addPoint(130, 100, 90, 0.6) ([130,100] color must be yellow)
Point2 : addPoint(100, 130, 90, 0.2) ([100,130] color must be blue)
Point3 : addPoint(130, 130, 90, 0.7) ([130,130] color must be orange)
And there is that I get :
Point1 is orange/red
Point2 is blue/yellow
Point3 is red
But I expect to have :
Point1 yellow, Point2 blue, Point3 orange
Between Points 1 and 2 yellow to blue gradient
Between Points 2 and 3, blue to orange gradient
Between points 1 and 3, yellow to orange gradient
This is very important because there is a legend to show which color match with values but because of this sum, this is not accurate at all..
So, I wanted to know if there is a way to have this kind of interpolation.

Thank you for your work.

Method to get value at a point X, Y

First of all thank you for the work you have done with WebGL-HeatMap library. I am using your library for a personal project. I encounter a major barrier because the library does not have any method to obtain the intensity of a given point.

Is there any way to get it?

Add git tag

Hello @pyalot ,
I am the member of the cdnjs project.
We want to host this library.
But there is a question want to ask.
Could you add git tag for repository?
It's helpful for user to know the version and status.
And is this library published on npm package?
Thanks for your help!

cdnjs/cdnjs#6746

Amount = Intensity

If each several points are added to the map with the same coordinates, shouldn't the whole point of the heatmap be that the intensity then automatically gets stronger at that coordinate.
I can add 100 points to the map with Intensity=1 and it just looks as it has gotten one hit.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.