jQuery HeatMap: The basic functionality of the Heatmap chart

A live JavaScript/jQuery example of jqxHeatMap, the jQWidgets HeatMap component, with its complete source code below. It is one of 8 jqxHeatMap demos for jQuery.

jqxHeatMap API used in this demo

Source code

To run it in your own page, load jqx.base.css, a theme and the library files below from npm (npm install jqwidgets-scripts) or the jsDelivr CDN, then add the markup and the script. jQuery is not required: jqxcore.js provides $. Getting started with jqxHeatMap shows the setup step by step.

The page loads jqx.base.css, a theme and these library files: jqxcore.js, jqxheatmap.js.

It also loads helper scripts of this demo site, which are not part of the library: demos.js (getWidth() and other layout helpers).

script.js

$(document).ready(function () {
    var xAxis = {
        labels: ['2015', '2016', '2017', '2018']
    };
    var yAxis = {
        labels: ['May', 'June', 'July', 'August']
    };

    var data = [
        [10, 17, 19, 28],
        [13, 16, 20, 27],
        [6, 18, 22, 22],
        [1, 21, 14, 30]
    ];

    $("#heatmap").jqxHeatMap({
        xAxis: xAxis,
        yAxis: yAxis,
        source: data,
        title: 'Number of sunny days during summer months',
        paletteSettings: {
            palette: [
                { value: 0, color: '#FCF4A3' },
                { value: 31, color: '#F9A602' },
            ],
        },
    });
});

body.html

<div id="heatmap"></div>

Learn more