Heatmap 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 Dugwood). 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..100);" under Internet Explorer, and "opacity:0..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:

$memory: Memory limit in bytes. Read Performance and optimization for more info
$step: Pixels 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)
$startStep: internal variable
$dot: Heat dots size, diameter of the dot in pixels
$heatmap: Show as heatmap (boolean)
$palette: Correction for palette, in case red squares show up instead of gradient dots (boolean)
$rainbow: Shows top left rainbow with number of clicks
$copyleft: Shows bottom right copyleft
$width: internal variable
$height: internal variable
$maxClicks: internal variable
$maxY: internal variable
$image: internal variable
$file: Destination 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
$path: Directory where images will be stored after generation (using $file format)
$cache: Directory where temporary images will be stored during generation (using $file format)
$error: internal variable, to be read if generate() returns false
$__colors: Gradient levels array: 5 ascending values in the range 0...127, defining those levels: blue, light blue, green, yellow, red
$__low: Low level of color: from 0 to 255 (try it as it's really hard to explain)
$__high: High level of color: from 0 to 255 (must be higher than $__low)
$__grey: Grey level where there's no clics: from 0 (black) to 255 (white)

Database class (HeatmapFromDatabase) parameters:

$host: MySQL host (server)
$user: MySQL user
$password: MySQL password
$database: MySQL database to use
$limit: Maximum number of results returned by each request call (limits memory use)
$link: internal variable
$query: Clicks 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
$maxQuery: Max 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:

$files: internal variable (files list to import)
$regular: Regular 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

 
Published by 119 on June 3, 2010 at 05:28 p.m..

Comments

No comment yet

Name(Mandatory field)
Email(Mandatory field)
Email(Mandatory field)
Website or blog
Characters left: 1000