Version française

Links


Information


Contact

  • Sales
  • Technical support

ClickHeat | Heatmap PHP class

Since release 1.2, heatmap generation is inside a PHP class. So you can use it without using ClickHeat, in your application (as long as you keep GPL info and the source of this class, ie Labsmedia). Please note that there's currently no transparency on the generated images, the transparency used in ClickHeat is made using CSS: "filter:alpha(opacity:[0 to 100]);" under Internet Explorer, and "opacity:[0 to 1];" under Gecko browsers (Mozilla, Firefox, etc). This may be a feature in the next releases (to add transparency in the rendered image)

How to use it:

Example is far the most easy way to explain this. So have a look into the examples/ directory, and look at the 2 examples inside

Main class (Heatmap) function:

generate($width, $height)generate a list of images representing a heatmap with a fixed width of $width. If $height is missing or 0, $height is calcutated using the memory available (to avoid a memory overflow). Result of this function is an array of various values, including the width, height, number of images and file paths of the final heatmap

Main class (Heatmap) parameters:

$memoryMemory limit in bytes. Read performance page for more info
$stepPixels grouping: instead of putting a dot at each X,Y location, clicks are grouped into 1 pixel in the middle of a $step x $step pixels square (speeds things up by limiting parsed pixels)
$startStepinternal variable
$dotHeat dots size, diameter of the dot in pixels
$heatmapShow as heatmap (boolean)
$paletteCorrection for palette, in case red squares show up instead of gradient dots (boolean)
$rainbowShows top left rainbow with number of clicks
$copyleftShows bottom right copyleft
$widthinternal variable
$heightinternal variable
$maxClicksinternal variable
$maxYinternal variable
$imageinternal variable
$fileDestination filename, including a %d which will be replaced by the number of the image, for example: image-%d.png will be replaced by image-0.png for first part of the image, image-1.png for second part and so on
$pathDirectory where images will be stored after generation (using $file format)
$cacheDirectory where temporary images will be stored during generation (using $file format)
$errorinternal variable, to be read if generate() returns false
$__colorsGradient levels array: 5 ascending values in the range 0...127, defining those levels: blue, light blue, green, yellow, red
$__lowLow level of color: from 0 to 255 (try it as it's really hard to explain)
$__highHigh level of color: from 0 to 255 (must be higher than $__low)
$__greyGrey level where there's no clics: from 0 (black) to 255 (white)

Database class (HeatmapFromDatabase) parameters:

$hostMySQL host (server)
$userMySQL user
$passwordMySQL password
$databaseMySQL database to use
$limitMaximum number of results returned by each request call (limits memory use)
$linkinternal variable
$queryClicks coordinates query (must contain two %d for the height limit), for example: SELECT COORDS_X, COORDS_Y FROM CLICKS WHERE COORDS_Y BETWEEN %d AND %d
$maxQueryMax Y coordinate query, for example: SELECT MAX(COORDS_Y) FROM CLICKS

File class (HeatmapFromFile) additional function:

addFile($file)adds the file $file to the list of files which will be imported (check for existence of the file, but doesn't return any error)

File class (HeatmapFromFile) parameters:

$filesinternal variable (files list to import)
$regularRegular expression to read file entries. First value in the result is the X value, second is Y. For more information, please read regular expressions syntax