Gradient
Fixed

jQuery HeatMap: Palette Mode

Palette modes.

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, jqxradiobutton.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: ['John', 'Marry', 'Alba', 'Steven', 'Josh', 'Alica', 'Robert', 'Kim', 'Ann', 'Paul', 'Regina', 'Dorothy'],
        opposedPosition: true
    };
    var yAxis = {
        labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
        opposedPosition: true
    };

    var data = [
        [49, 39, 44, 55, 60],
        [53, 38, 26, 48, 33],
        [22, 17, 36, 10, 18],
        [17, 60, 60, 23, 19],
        [47, 47, 38, 60, 10],
        [13, 23, 30, 60, 10],
        [21, 26, 13, 33, 14],
        [53, 21, 45, 29, 60],
        [34, 60, 58, 51, 43],
        [10, 12, 58, 14, 21],
        [55, 58, 12, 22, 49],
        [18, 23, 56, 59, 53],
    ];

    $("#heatmap").jqxHeatMap({
        xAxis: xAxis,
        yAxis: yAxis,
        source: data,
        title: 'Car sales revenue per employee(in 1000 €)',
        legendSettings: {
            position: 'Bottom'
        },
        paletteSettings: {
            palette: [
                { value: 10, color: '#6bbd49' },
                { value: 30, color: '#22aaaa' },
                { value: 60, color: '#53b9e6' },
            ]
        }
    });

    $(".jqxradiobutton").jqxRadioButton({ width: 90, height: 25 });
    $("#gradient").jqxRadioButton({ checked: true });

    $('#gradient').on('checked', function (event) {
        $("#heatmap").jqxHeatMap('setPaletteType', 'Gradient');
    });
    $('#fixed').on('checked', function (event) {
        $("#heatmap").jqxHeatMap('setPaletteType', 'Fixed');
    });
});

body.html

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

<div id="palette-mode">
    <label for="jqxdropdownlist">Palette Type:</label>

    <div class="radio-buttons">
        <div id="gradient" class="jqxradiobutton">Gradient</div>
        <div id="fixed" class="jqxradiobutton">Fixed</div>
    </div>
</div>

Learn more

More jQuery HeatMap demos