Introduction
Heatmaps
Cal-HeatMap

- Create index.html and copy paste below code,
In above code base, you will notice references for D3.js and cal-heatmap.min.js
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <title>Cal-Heatmap Samples</title>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
- <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
- <script type="text/javascript" src="http://d3js.org/d3.v3.min.js"></script>
- <script type="text/javascript" src="http://cdn.jsdelivr.net/cal-heatmap/3.3.10/cal-heatmap.min.js"></script>
- <link rel="stylesheet" href="http://cdn.jsdelivr.net/cal-heatmap/3.3.10/cal-heatmap.css" />
- </head>
- <body>
- <div class="container">
- <div class="page-header">
- <h2>
- Cal-HeatMap Samples</h2>
- </div>
- <div class="row">
- <div class="col-lg-6">
- <div class="panel panel-default">
- <div class="panel-heading"><span class="glyphicon glyphicon-equalizer"></span> Service Call Statistics</div>
- <div class="panel-body">
- <div id="heatmap-navigation">
- <button id="heatmap-previous" style="margin-bottom: 5px;" class="btn-xs"><i class="glyphicon glyphicon-chevron-left"></i></button>
- <button id="heatmap-next" style="margin-bottom: 5px;" class="btn-xs"><i class="glyphicon glyphicon-chevron-right"></i></button>
- </div>
- <div id="cal-heatmap">
- </div>
- </div>
- </div>
- </div>
- </div>
- <script type="text/javascript">
- var cal = new CalHeatMap();
- cal.init({
- domain: "month",
- subDomain: "day",
- cellSize: 20,
- itemName: ["service ticket", "service tickets"],
- data: {
- "1452019700": 40,
- "1454688100": 50,
- "1452710900": 5,
- "1452883700": 15,
- "1453142900": 15,
- "1453488500": 30,
- "1456239700": 80,
- "1453662300": 20,
- "1455130100": 60,
- "1455562100": 70,
- "1455131100": 10,
- "1456166900": 30,
- "1456399000": 12,
- "1451674100": 90
- },
- subDomainTextFormat: "%d",
- range: 3,
- displayLegend: true,
- domainMargin: 20,
- animationDuration: 800,
- domainDynamicDimension: false,
- start: new Date(2016, 01, 01),
- end: new Date(2016, 02, 26),
- scale: [10, 20, 80],
- previousSelector: "#heatmap-previous",
- nextSelector: "#heatmap-next",
- });
- </script>
- </body>
- </html>
As a standard, I am displaying my heatmap in a bootstrap panel.To generate and render heatmap, from the above code snippet the following elements are important,o <DIV> element<div id="cal-heatmap"></div>o Init() function of CalHeatMapvar cal = new CalHeatMap();cal.init({.........});This init() function has multiple options to customize our calender and overlay data on it. This will be discussed in subsequent articles. - Open index.html in a browser and see how heatmap is getting generated. Refer to the following screenshot for the same.

- Select the previous and next buttons to navigate through a heatmap.
The above representation quickly highlights how calls are made by a service center in a month, the trend, and which days of a month are busy days for a service center. By showing such information further business decisions can be made easily.
So, start thinking and implementing how best we can visualize our data with the context and use of Cal-HeatMap.js.

Shubham KumarPosted Feb 26, 2016, 5:49 AM
Interesting article nice
Sibeesh VenuPosted Feb 26, 2016, 4:35 AM
Nice Share
Pramod ThakurPosted Feb 25, 2016, 2:54 AM
welcome to community... and thanks for sharing