From 3aff12d4e47fd1ba2a33e1ed8a2667dabded7d35 Mon Sep 17 00:00:00 2001 From: Kamisama Date: Wed, 16 Oct 2013 23:59:46 -0400 Subject: [PATCH] Build files for 3.3.5 --- cal-heatmap.js | 1770 ++++++++++++++++++++++--------------- cal-heatmap.min.js | 8 +- cal-heatmap.source-map.js | 2 +- test/test.js | 2 +- 4 files changed, 1067 insertions(+), 715 deletions(-) diff --git a/cal-heatmap.js b/cal-heatmap.js index ffde3a38..ecb6ba9e 100755 --- a/cal-heatmap.js +++ b/cal-heatmap.js @@ -1,18 +1,17 @@ -/*! cal-heatmap v3.3.3 (Wed Oct 09 2013 18:17:57) +/*! cal-heatmap v3.3.5 (Wed Oct 16 2013 23:56:23) * --------------------------------------------- - * Cal-Heatmap is a javascript module to create calendar heatmap to visualize time series data, a la github contribution graph + * Cal-Heatmap is a javascript module to create calendar heatmap to visualize time series data * https://github.com/kamisama/cal-heatmap * Licensed under the MIT license * Copyright 2013 Wan Qi Chen */ var CalHeatMap = function() { - "use strict"; var self = this; - var allowedDataType = ["json", "csv", "tsv", "txt"]; + this.allowedDataType = ["json", "csv", "tsv", "txt"]; // Default settings this.options = { @@ -43,7 +42,7 @@ var CalHeatMap = function() { domainGutter: 2, - domainMargin: [0,0,0,0], + domainMargin: [0, 0, 0, 0], domain: "hour", @@ -72,7 +71,7 @@ var CalHeatMap = function() { // URL, where to fetch the original datas data: "", - dataType: allowedDataType[0], + dataType: this.allowedDataType[0], // Whether to consider missing date:value from the datasource // as equal to 0, or just leave them as missing @@ -120,7 +119,7 @@ var CalHeatMap = function() { // ================================================ // Threshold for the legend - legend: [10,20,30,40], + legend: [10, 20, 30, 40], // Whether to display the legend displayLegend: true, @@ -234,6 +233,7 @@ var CalHeatMap = function() { onClick: null, // Callback after painting the empty calendar + // Can be used to trigger an API call, once the calendar is ready to be filled afterLoad: null, // Callback after loading the next domain in the calendar @@ -294,8 +294,7 @@ var CalHeatMap = function() { connector: "at" }, extractUnit: function(d) { - var dt = new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes()); - return dt.getTime(); + return new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes()).getTime(); } }, "hour": { @@ -311,18 +310,22 @@ var CalHeatMap = function() { } return Math.ceil(total / self.options.colLimit); } - return self.options.rowLimit || 6; }, + return self.options.rowLimit || 6; + }, column: function(d) { if (self.options.colLimit > 0) { return self.options.colLimit; } switch(self.options.domain) { - case "day": return self.options.rowLimit > 0 ? Math.ceil(24 / self.options.rowLimit) : 4; - case "week": return self.options.rowLimit > 0 ? Math.ceil(24 * 7 / self.options.rowLimit) : 28; - case "month": return self.options.rowLimit > 0 ? - Math.ceil(24 * 31 / self.options.rowLimit) : - ((self.options.domainDynamicDimension ? self.getEndOfMonth(d).getDate(): 31) * 4); + case "day": + return self.options.rowLimit > 0 ? Math.ceil(24 / self.options.rowLimit) : 4; + case "week": + return self.options.rowLimit > 0 ? Math.ceil(24 * 7 / self.options.rowLimit) : 28; + case "month": + return self.options.rowLimit > 0 ? + Math.ceil(24 * 31 / self.options.rowLimit) : + ((self.options.domainDynamicDimension ? self.getEndOfMonth(d).getDate(): 31) * 4); } }, position: { @@ -343,8 +346,10 @@ var CalHeatMap = function() { y: function(d) { if (self.options.colLimit > 0 || self.options.rowLimit > 0) { switch(self.options.domain) { - case "month": return Math.floor((d.getHours() + (d.getDate()-1)*24) % self._domainType.hour.row(d)); - case "week": return Math.floor((d.getHours() + self.getWeekDay(d)*24) % self._domainType.hour.row(d)); + case "month": + return Math.floor((d.getHours() + (d.getDate()-1)*24) % self._domainType.hour.row(d)); + case "week": + return Math.floor((d.getHours() + self.getWeekDay(d)*24) % self._domainType.hour.row(d)); } } @@ -357,8 +362,7 @@ var CalHeatMap = function() { connector: "at" }, extractUnit: function(d) { - var dt = new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours()); - return dt.getTime(); + return new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours()).getTime(); } }, "day": { @@ -368,9 +372,14 @@ var CalHeatMap = function() { if (self.options.colLimit > 0) { var total = 0; switch(self.options.domain) { - case "year": total = self.getDayCountInYear(d); break; - case "month": total = self.getDayCountInMonth(d); break; - case "week": total = 7; + case "year": + total = self.getDayCountInYear(d); + break; + case "month": + total = self.getDayCountInMonth(d); + break; + case "week": + total = 7; } return Math.ceil(total / self.options.colLimit); } @@ -382,48 +391,54 @@ var CalHeatMap = function() { } d = new Date(d); + switch(self.options.domain) { - case "year": - if (self.options.rowLimit > 0) { - var dayCountInMonth = self.options.domainDynamicDimension ? self.getDayCountInYear(d) : 366; - return Math.ceil(dayCountInMonth / self.options.rowLimit); - } - return (self.options.domainDynamicDimension ? (self.getWeekNumber(new Date(d.getFullYear(), 11, 31)) - self.getWeekNumber(new Date(d.getFullYear(), 0)) + 1): 54); - case "month": - if (self.options.rowLimit > 0) { - var dayNumber = self.options.domainDynamicDimension ? new Date(d.getFullYear(), d.getMonth()+1, 0).getDate() : 31; - return Math.ceil(dayNumber / self.options.rowLimit); - } + case "year": + if (self.options.rowLimit > 0) { + var dayCountInMonth = self.options.domainDynamicDimension ? self.getDayCountInYear(d) : 366; + return Math.ceil(dayCountInMonth / self.options.rowLimit); + } + return (self.options.domainDynamicDimension ? (self.getWeekNumber(new Date(d.getFullYear(), 11, 31)) - self.getWeekNumber(new Date(d.getFullYear(), 0)) + 1): 54); + case "month": + if (self.options.rowLimit > 0) { + var dayNumber = self.options.domainDynamicDimension ? new Date(d.getFullYear(), d.getMonth()+1, 0).getDate() : 31; + return Math.ceil(dayNumber / self.options.rowLimit); + } - if (self.options.verticalOrientation) { - return 6; - } - return self.options.domainDynamicDimension ? (self.getWeekNumber(new Date(d.getFullYear(), d.getMonth()+1, 0)) - self.getWeekNumber(d) + 1): 6; - case "week": return Math.ceil(7 / self._domainType.day.row(d)); + if (self.options.verticalOrientation) { + return 6; + } + return self.options.domainDynamicDimension ? (self.getWeekNumber(new Date(d.getFullYear(), d.getMonth()+1, 0)) - self.getWeekNumber(d) + 1): 6; + case "week": + return Math.ceil(7 / self._domainType.day.row(d)); } }, position: { x: function(d) { switch(self.options.domain) { - case "week": return Math.floor(self.getWeekDay(d) / self._domainType.day.row(d)); - case "month": - if (self.options.colLimit > 0 || self.options.rowLimit > 0) { - return Math.floor((d.getDate() - 1)/ self._domainType.day.row(d)); - } - return self.getWeekNumber(d) - self.getWeekNumber(new Date(d.getFullYear(), d.getMonth())); - case "year": - if (self.options.colLimit > 0 || self.options.rowLimit > 0) { - return Math.floor((self.getDayOfYear(d) - 1) / self._domainType.day.row(d)); - } - return self.getWeekNumber(d); + case "week": + return Math.floor(self.getWeekDay(d) / self._domainType.day.row(d)); + case "month": + if (self.options.colLimit > 0 || self.options.rowLimit > 0) { + return Math.floor((d.getDate() - 1)/ self._domainType.day.row(d)); + } + return self.getWeekNumber(d) - self.getWeekNumber(new Date(d.getFullYear(), d.getMonth())); + case "year": + if (self.options.colLimit > 0 || self.options.rowLimit > 0) { + return Math.floor((self.getDayOfYear(d) - 1) / self._domainType.day.row(d)); + } + return self.getWeekNumber(d); } }, y: function(d) { if (self.options.colLimit > 0 || self.options.rowLimit > 0) { switch(self.options.domain) { - case "year": return Math.floor((self.getDayOfYear(d) - 1) % self._domainType.day.row(d)); - case "week": return Math.floor(self.getWeekDay(d) % self._domainType.day.row(d)); - case "month": return Math.floor((d.getDate() - 1) % self._domainType.day.row(d)); + case "year": + return Math.floor((self.getDayOfYear(d) - 1) % self._domainType.day.row(d)); + case "week": + return Math.floor(self.getWeekDay(d) % self._domainType.day.row(d)); + case "month": + return Math.floor((d.getDate() - 1) % self._domainType.day.row(d)); } } @@ -436,8 +451,7 @@ var CalHeatMap = function() { connector: "on" }, extractUnit: function(d) { - var dt = new Date(d.getFullYear(), d.getMonth(), d.getDate()); - return dt.getTime(); + return new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime(); } }, "week": { @@ -456,26 +470,29 @@ var CalHeatMap = function() { d = new Date(d); switch(self.options.domain) { - case "year": return 54; - case "month": return self.getWeekNumber(new Date(d.getFullYear(), d.getMonth()+1, 0)) - self.getWeekNumber(d); - default: return 1; + case "year": + return 54; + case "month": + return self.getWeekNumber(new Date(d.getFullYear(), d.getMonth()+1, 0)) - self.getWeekNumber(d); + default: + return 1; } }, position: { x: function(d) { switch(self.options.domain) { - case "year": - if (self.options.colLimit > 0 || self.options.rowLimit > 0) { - return Math.floor(self.getWeekNumber(d) / self._domainType.week.row(d)); - } - return self.getWeekNumber(d); - case "month": - var weekNumberInMonth = self.getMonthWeekNumber(d); - if (self.options.colLimit > 0 || self.options.rowLimit > 0) { + case "year": + if (self.options.colLimit > 0 || self.options.rowLimit > 0) { + return Math.floor(self.getWeekNumber(d) / self._domainType.week.row(d)); + } + return self.getWeekNumber(d); + case "month": + var weekNumberInMonth = self.getMonthWeekNumber(d); + if (self.options.colLimit > 0 || self.options.rowLimit > 0) { - return Math.floor((weekNumberInMonth - 1) / self._domainType.week.row(d)); - } - return weekNumberInMonth; + return Math.floor((weekNumberInMonth - 1) / self._domainType.week.row(d)); + } + return weekNumberInMonth; } }, y: function(d) { @@ -523,8 +540,7 @@ var CalHeatMap = function() { connector: "on" }, extractUnit: function(d) { - var dt = new Date(d.getFullYear(), d.getMonth()); - return dt.getTime(); + return new Date(d.getFullYear(), d.getMonth()).getTime(); } }, "year": { @@ -542,37 +558,41 @@ var CalHeatMap = function() { connector: "on" }, extractUnit: function(d) { - var dt = new Date(d.getFullYear()); - return dt.getTime(); + return new Date(d.getFullYear()).getTime(); } } }; for (var type in this._domainType) { - this._domainType["x_" + type] = {}; - this._domainType["x_" + type].name = "x_" + type; - this._domainType["x_" + type].level = this._domainType[type].level; - this._domainType["x_" + type].row = this._domainType[type].column; - this._domainType["x_" + type].column = this._domainType[type].row; - this._domainType["x_" + type].position = {}; - this._domainType["x_" + type].position.x = this._domainType[type].position.y; - this._domainType["x_" + type].position.y = this._domainType[type].position.x; - this._domainType["x_" + type].format = this._domainType[type].format; - this._domainType["x_" + type].extractUnit = this._domainType[type].extractUnit; + if (this._domainType.hasOwnProperty(type)) { + this._domainType["x_" + type] = {}; + this._domainType["x_" + type].name = "x_" + type; + this._domainType["x_" + type].level = this._domainType[type].level; + this._domainType["x_" + type].row = this._domainType[type].column; + this._domainType["x_" + type].column = this._domainType[type].row; + this._domainType["x_" + type].position = {}; + this._domainType["x_" + type].position.x = this._domainType[type].position.y; + this._domainType["x_" + type].position.y = this._domainType[type].position.x; + this._domainType["x_" + type].format = this._domainType[type].format; + this._domainType["x_" + type].extractUnit = this._domainType[type].extractUnit; + } } // Exception: always return the maximum number of weeks // to align the label vertically + /* jshint camelcase:false */ this._domainType.x_day.row = function(d) { d = new Date(d); switch(self.options.domain) { - case "year": return (self.options.domainDynamicDimension ? (self.getWeekNumber(new Date(d.getFullYear(), 11, 31)) - self.getWeekNumber(new Date(d.getFullYear(), 0)) + 1): 54); - case "month": - if (!self.options.verticalOrientation) { - return 6; - } - return self.options.domainDynamicDimension ? (self.getWeekNumber(new Date(d.getFullYear(), d.getMonth()+1, 0)) - self.getWeekNumber(d) + 1): 6; - case "week": return 1; + case "year": + return (self.options.domainDynamicDimension ? (self.getWeekNumber(new Date(d.getFullYear(), 11, 31)) - self.getWeekNumber(new Date(d.getFullYear(), 0)) + 1): 54); + case "month": + if (!self.options.verticalOrientation) { + return 6; + } + return self.options.domainDynamicDimension ? (self.getWeekNumber(new Date(d.getFullYear(), d.getMonth()+1, 0)) - self.getWeekNumber(d) + 1): 6; + case "week": + return 1; } }; @@ -619,7 +639,7 @@ var CalHeatMap = function() { * Display the graph for the first time * @return bool True if the calendar is created */ - function _init() { + this._init = function() { self.getDomain(self.options.start).map(function(d) { return d.getTime(); }).map(function(d) { self._domains.set(d, self.getSubDomain(d).map(function(d) { return {t: self._domainType[self.options.subDomain].extractUnit(d), v: null}; })); @@ -627,7 +647,7 @@ var CalHeatMap = function() { self.root = d3.select(self.options.itemSelector).append("svg").attr("class", "cal-heatmap-container"); - self.tooltip = d3.select(self.options.itemSelector).attr("style", "position:relative;").append("div") + self.tooltip = d3.select(self.options.itemSelector).attr("style", d3.select(self.options.itemSelector).attr("style") + "position:relative;").append("div") .attr("class", "ch-tooltip") ; @@ -636,79 +656,75 @@ var CalHeatMap = function() { self.Legend = new Legend(self); if (self.options.paintOnLoad) { + _initCalendar(); + } - self.verticalDomainLabel = (self.options.label.position === "top" || self.options.label.position === "bottom"); + return true; + }; - self.domainVerticalLabelHeight = self.options.label.height === null ? Math.max(25, self.options.cellSize*2): self.options.label.height; - self.domainHorizontalLabelWidth = 0; + function _initCalendar() { + self.verticalDomainLabel = (self.options.label.position === "top" || self.options.label.position === "bottom"); - if (self.options.domainLabelFormat === "" && self.options.label.height === null) { - self.domainVerticalLabelHeight = 0; - } + self.domainVerticalLabelHeight = self.options.label.height === null ? Math.max(25, self.options.cellSize*2): self.options.label.height; + self.domainHorizontalLabelWidth = 0; - if (!self.verticalDomainLabel) { - self.domainVerticalLabelHeight = 0; - self.domainHorizontalLabelWidth = self.options.label.width; - } + if (self.options.domainLabelFormat === "" && self.options.label.height === null) { + self.domainVerticalLabelHeight = 0; + } - // @todo: check validity - if (typeof self.options.domainMargin === "number") { - self.options.domainMargin = [self.options.domainMargin, self.options.domainMargin, self.options.domainMargin, self.options.domainMargin]; - } + if (!self.verticalDomainLabel) { + self.domainVerticalLabelHeight = 0; + self.domainHorizontalLabelWidth = self.options.label.width; + } - self.paint(); + self.paint(); - // =========================================================================// - // ATTACHING DOMAIN NAVIGATION EVENT // - // =========================================================================// - if (self.options.nextSelector !== false) { - d3.select(self.options.nextSelector).on("click." + self.options.itemNamespace, function() { - d3.event.preventDefault(); - return self.loadNextDomain(); - }); - } + // =========================================================================// + // ATTACHING DOMAIN NAVIGATION EVENT // + // =========================================================================// + if (self.options.nextSelector !== false) { + d3.select(self.options.nextSelector).on("click." + self.options.itemNamespace, function() { + d3.event.preventDefault(); + return self.loadNextDomain(1); + }); + } - if (self.options.previousSelector !== false) { - d3.select(self.options.previousSelector).on("click." + self.options.itemNamespace, function() { - d3.event.preventDefault(); - return self.loadPreviousDomain(); - }); - } + if (self.options.previousSelector !== false) { + d3.select(self.options.previousSelector).on("click." + self.options.itemNamespace, function() { + d3.event.preventDefault(); + return self.loadPreviousDomain(1); + }); + } - // Display legend if needed - if (self.options.displayLegend) { - self.Legend.redraw(self.graphDim.width - self.options.domainGutter - self.options.cellPadding); - } + self.Legend.redraw(self.graphDim.width - self.options.domainGutter - self.options.cellPadding); + self.afterLoad(); - if (self.options.afterLoad !== null) { - self.afterLoad(); - } + var domains = self.getDomainKeys(); - // Fill the graph with some datas - if (self.options.loadOnInit) { - var domains = self.getDomainKeys(); - self.getDatas( - self.options.data, - new Date(domains[0]), - self.getSubDomain(domains[domains.length-1]).pop(), - function() { - self.fill(); - self.onComplete(); - } - ); - } else { - self.onComplete(); - } + // Fill the graph with some datas + if (self.options.loadOnInit) { + self.getDatas( + self.options.data, + new Date(domains[0]), + self.getSubDomain(domains[domains.length-1]).pop(), + function() { + self.fill(); + self.onComplete(); + } + ); + } else { + self.onComplete(); } - return true; + self.checkIfMinDomainIsReached(domains[0]); + self.checkIfMaxDomainIsReached(self.getNextDomain().getTime()); } // Return the width of the domain block, without the domain gutter // @param int d Domain start timestamp function w(d, outer) { var width = self.options.cellSize*self._domainType[self.options.subDomain].column(d) + self.options.cellPadding*self._domainType[self.options.subDomain].column(d); - if (typeof outer !== "undefined" && outer === true) { + if (arguments.length === 2 && outer === true) { return width += self.domainHorizontalLabelWidth + self.options.domainGutter + self.options.domainMargin[1] + self.options.domainMargin[3]; } return width; @@ -717,7 +733,7 @@ var CalHeatMap = function() { // Return the height of the domain block, without the domain gutter function h(d, outer) { var height = self.options.cellSize*self._domainType[self.options.subDomain].row(d) + self.options.cellPadding*self._domainType[self.options.subDomain].row(d); - if (typeof outer !== "undefined" && outer === true) { + if (arguments.length === 2 && outer === true) { height += self.options.domainGutter + self.domainVerticalLabelHeight + self.options.domainMargin[0] + self.options.domainMargin[2]; } return height; @@ -730,7 +746,9 @@ var CalHeatMap = function() { */ this.paint = function(navigationDir) { - if (typeof navigationDir === "undefined") { + var options = self.options; + + if (arguments.length === 0) { navigationDir = false; } @@ -763,7 +781,7 @@ var CalHeatMap = function() { return h(d, true); }) .attr("x", function(d) { - if (self.options.verticalOrientation) { + if (options.verticalOrientation) { self.graphDim.width = w(d, true); return 0; } else { @@ -771,7 +789,7 @@ var CalHeatMap = function() { } }) .attr("y", function(d) { - if (self.options.verticalOrientation) { + if (options.verticalOrientation) { return getDomainPosition(d, self.graphDim, "height", h(d, true)); } else { self.graphDim.height = h(d, true); @@ -781,16 +799,21 @@ var CalHeatMap = function() { .attr("class", function(d) { var classname = "graph-domain"; var date = new Date(d); - switch(self.options.domain) { - case "hour": classname += " h_" + date.getHours(); + switch(options.domain) { + case "hour": + classname += " h_" + date.getHours(); /* falls through */ - case "day": classname += " d_" + date.getDate() + " dy_" + date.getDay(); + case "day": + classname += " d_" + date.getDate() + " dy_" + date.getDay(); /* falls through */ - case "week": classname += " w_" + self.getWeekNumber(date); + case "week": + classname += " w_" + self.getWeekNumber(date); /* falls through */ - case "month": classname += " m_" + (date.getMonth() + 1); + case "month": + classname += " m_" + (date.getMonth() + 1); /* falls through */ - case "year": classname += " y_" + date.getFullYear(); + case "year": + classname += " y_" + date.getFullYear(); } return classname; }) @@ -801,37 +824,37 @@ var CalHeatMap = function() { function getDomainPosition(domainIndex, graphDim, axis, domainDim) { var tmp = 0; switch(navigationDir) { - case false: - tmp = graphDim[axis]; + case false: + tmp = graphDim[axis]; - graphDim[axis] += domainDim; - self.domainPosition.setPosition(domainIndex, tmp); - return tmp; + graphDim[axis] += domainDim; + self.domainPosition.setPosition(domainIndex, tmp); + return tmp; - case self.NAVIGATE_RIGHT: - self.domainPosition.setPosition(domainIndex, graphDim[axis]); + case self.NAVIGATE_RIGHT: + self.domainPosition.setPosition(domainIndex, graphDim[axis]); - enteringDomainDim = domainDim; - exitingDomainDim = self.domainPosition.getPositionFromIndex(1); + enteringDomainDim = domainDim; + exitingDomainDim = self.domainPosition.getPositionFromIndex(1); - self.domainPosition.shiftRightBy(exitingDomainDim); - return graphDim[axis]; + self.domainPosition.shiftRightBy(exitingDomainDim); + return graphDim[axis]; - case self.NAVIGATE_LEFT: - tmp = -domainDim; + case self.NAVIGATE_LEFT: + tmp = -domainDim; - enteringDomainDim = -tmp; - exitingDomainDim = graphDim[axis] - self.domainPosition.getLast(); + enteringDomainDim = -tmp; + exitingDomainDim = graphDim[axis] - self.domainPosition.getLast(); - self.domainPosition.setPosition(domainIndex, tmp); - self.domainPosition.shiftLeftBy(enteringDomainDim); - return tmp; + self.domainPosition.setPosition(domainIndex, tmp); + self.domainPosition.shiftLeftBy(enteringDomainDim); + return tmp; } } svg.append("rect") - .attr("width", function(d) { return w(d, true) - self.options.domainGutter - self.options.cellPadding; }) - .attr("height", function(d) { return h(d, true) - self.options.domainGutter - self.options.cellPadding; }) + .attr("width", function(d) { return w(d, true) - options.domainGutter - options.cellPadding; }) + .attr("height", function(d) { return h(d, true) - options.domainGutter - options.cellPadding; }) .attr("class", "domain-background") ; @@ -840,17 +863,17 @@ var CalHeatMap = function() { // =========================================================================// var subDomainSvgGroup = svg.append("svg") .attr("x", function() { - if (self.options.label.position === "left") { - return self.domainHorizontalLabelWidth + self.options.domainMargin[3]; + if (options.label.position === "left") { + return self.domainHorizontalLabelWidth + options.domainMargin[3]; } else { - return self.options.domainMargin[3]; + return options.domainMargin[3]; } }) .attr("y", function() { - if (self.options.label.position === "top") { - return self.domainVerticalLabelHeight + self.options.domainMargin[0]; + if (options.label.position === "top") { + return self.domainVerticalLabelHeight + options.domainMargin[0]; } else { - return self.options.domainMargin[0]; + return options.domainMargin[0]; } }) .attr("class", "graph-subdomain-group") @@ -866,30 +889,30 @@ var CalHeatMap = function() { rect .append("rect") .attr("class", function(d) { - return "graph-rect" + self.getHighlightClassName(d.t) + (self.options.onClick !== null ? " hover_cursor": ""); + return "graph-rect" + self.getHighlightClassName(d.t) + (options.onClick !== null ? " hover_cursor": ""); }) - .attr("width", self.options.cellSize) - .attr("height", self.options.cellSize) + .attr("width", options.cellSize) + .attr("height", options.cellSize) .attr("x", function(d) { return self.positionSubDomainX(d.t); }) .attr("y", function(d) { return self.positionSubDomainY(d.t); }) .on("click", function(d) { - if (self.options.onClick !== null) { + if (options.onClick !== null) { return self.onClick(new Date(d.t), d.v); } }) .call(function(selection) { - if (self.options.cellRadius > 0) { + if (options.cellRadius > 0) { selection - .attr("rx", self.options.cellRadius) - .attr("ry", self.options.cellRadius) + .attr("rx", options.cellRadius) + .attr("ry", options.cellRadius) ; } - if (self.legendScale !== null && self.options.legendColors !== null && self.options.legendColors.hasOwnProperty("base")) { - selection.attr("fill", self.options.legendColors.base); + if (self.legendScale !== null && options.legendColors !== null && options.legendColors.hasOwnProperty("base")) { + selection.attr("fill", options.legendColors.base); } - if (self.options.tooltip) { + if (options.tooltip) { selection.on("mouseover", function(d) { var domainNode = this.parentNode.parentNode.parentNode; @@ -900,8 +923,8 @@ var CalHeatMap = function() { self.tooltip.attr("style", "display: block; " + - "left: " + (self.positionSubDomainX(d.t) - self.tooltip[0][0].offsetWidth/2 + self.options.cellSize/2 + parseInt(domainNode.getAttribute("x"), 10)) + "px; " + - "top: " + (self.positionSubDomainY(d.t) - self.tooltip[0][0].offsetHeight - self.options.cellSize/2 + parseInt(domainNode.getAttribute("y"), 10)) + "px;") + "left: " + (self.positionSubDomainX(d.t) - self.tooltip[0][0].offsetWidth/2 + options.cellSize/2 + parseInt(domainNode.getAttribute("x"), 10)) + "px; " + + "top: " + (self.positionSubDomainY(d.t) - self.tooltip[0][0].offsetHeight - options.cellSize/2 + parseInt(domainNode.getAttribute("y"), 10)) + "px;") ; }); @@ -915,101 +938,118 @@ var CalHeatMap = function() { ; // Appending a title to each subdomain - if (!self.options.tooltip) { - rect.append("title").text(function(d){ return self.formatDate(new Date(d.t), self.options.subDomainDateFormat); }); + if (!options.tooltip) { + rect.append("title").text(function(d){ return self.formatDate(new Date(d.t), options.subDomainDateFormat); }); } // =========================================================================// // PAINTING LABEL // // =========================================================================// - if (self.options.domainLabelFormat !== "") { + if (options.domainLabelFormat !== "") { svg.append("text") .attr("class", "graph-label") .attr("y", function(d) { - var y = self.options.domainMargin[0]; - switch(self.options.label.position) { - case "top": y += self.domainVerticalLabelHeight/2; break; - case "bottom": y += h(d) + self.domainVerticalLabelHeight/2; + var y = options.domainMargin[0]; + switch(options.label.position) { + case "top": + y += self.domainVerticalLabelHeight/2; + break; + case "bottom": + y += h(d) + self.domainVerticalLabelHeight/2; } - return y + self.options.label.offset.y * + return y + options.label.offset.y * ( - ((self.options.label.rotate === "right" && self.options.label.position === "right") || - (self.options.label.rotate === "left" && self.options.label.position === "left")) ? + ((options.label.rotate === "right" && options.label.position === "right") || + (options.label.rotate === "left" && options.label.position === "left")) ? -1: 1 ); }) .attr("x", function(d){ - var x = self.options.domainMargin[3]; - switch(self.options.label.position) { - case "right": x += w(d); break; - case "bottom": - case "top": x += w(d)/2; + var x = options.domainMargin[3]; + switch(options.label.position) { + case "right": + x += w(d); + break; + case "bottom": + case "top": + x += w(d)/2; } - if (self.options.label.align === "right") { - return x + self.domainHorizontalLabelWidth - self.options.label.offset.x * - (self.options.label.rotate === "right" ? -1: 1); + if (options.label.align === "right") { + return x + self.domainHorizontalLabelWidth - options.label.offset.x * + (options.label.rotate === "right" ? -1: 1); } - return x + self.options.label.offset.x; + return x + options.label.offset.x; }) .attr("text-anchor", function() { - switch(self.options.label.align) { - case "start": - case "left": return "start"; - case "end": - case "right": return "end"; - default: return "middle"; + switch(options.label.align) { + case "start": + case "left": + return "start"; + case "end": + case "right": + return "end"; + default: + return "middle"; } }) .attr("dominant-baseline", function() { return self.verticalDomainLabel ? "middle": "top"; }) - .text(function(d) { return self.formatDate(new Date(d), self.options.domainLabelFormat); }) + .text(function(d) { return self.formatDate(new Date(d), options.domainLabelFormat); }) .call(domainRotate) ; } function domainRotate(selection) { - switch (self.options.label.rotate) { - case "right": - selection - .attr("transform", function(d) { - var s = "rotate(90), "; - switch(self.options.label.position) { - case "right": s += "translate(-" + w(d) + " , -" + w(d) + ")"; break; - case "left": s += "translate(0, -" + self.domainHorizontalLabelWidth + ")"; break; - } + switch (options.label.rotate) { + case "right": + selection + .attr("transform", function(d) { + var s = "rotate(90), "; + switch(options.label.position) { + case "right": + s += "translate(-" + w(d) + " , -" + w(d) + ")"; + break; + case "left": + s += "translate(0, -" + self.domainHorizontalLabelWidth + ")"; + break; + } - return s; - }); - break; - case "left": - selection - .attr("transform", function(d) { - var s = "rotate(270), "; - switch(self.options.label.position) { - case "right": s += "translate(-" + (w(d) + self.domainHorizontalLabelWidth) + " , " + w(d) + ")"; break; - case "left": s += "translate(-" + (self.domainHorizontalLabelWidth) + " , " + self.domainHorizontalLabelWidth + ")"; break; - } + return s; + }); + break; + case "left": + selection + .attr("transform", function(d) { + var s = "rotate(270), "; + switch(options.label.position) { + case "right": + s += "translate(-" + (w(d) + self.domainHorizontalLabelWidth) + " , " + w(d) + ")"; + break; + case "left": + s += "translate(-" + (self.domainHorizontalLabelWidth) + " , " + self.domainHorizontalLabelWidth + ")"; + break; + } - return s; - }); - break; + return s; + }); + break; } } // =========================================================================// // PAINTING DOMAIN SUBDOMAIN CONTENT // // =========================================================================// - if (self.options.subDomainTextFormat !== null) { + if (options.subDomainTextFormat !== null) { rect .append("text") .attr("class", function(d) { return "subdomain-text" + self.getHighlightClassName(d.t); }) - .attr("x", function(d) { return self.positionSubDomainX(d.t) + self.options.cellSize/2; }) - .attr("y", function(d) { return self.positionSubDomainY(d.t) + self.options.cellSize/2; }) + .attr("x", function(d) { return self.positionSubDomainX(d.t) + options.cellSize/2; }) + .attr("y", function(d) { return self.positionSubDomainY(d.t) + options.cellSize/2; }) .attr("text-anchor", "middle") .attr("dominant-baseline", "central") - .text(function(d){ return self.formatDate(new Date(d.t), self.options.subDomainTextFormat); }) + .text(function(d){ return self.formatDate(new Date(d.t), options.subDomainTextFormat); }) ; } @@ -1018,12 +1058,12 @@ var CalHeatMap = function() { // =========================================================================// if (navigationDir !== false) { - domainSvg.transition().duration(self.options.animationDuration) + domainSvg.transition().duration(options.animationDuration) .attr("x", function(d){ - return self.options.verticalOrientation ? 0: self.domainPosition.getPosition(d); + return options.verticalOrientation ? 0: self.domainPosition.getPosition(d); }) .attr("y", function(d){ - return self.options.verticalOrientation? self.domainPosition.getPosition(d): 0; + return options.verticalOrientation? self.domainPosition.getPosition(d): 0; }) ; } @@ -1031,29 +1071,33 @@ var CalHeatMap = function() { var tempWidth = self.graphDim.width; var tempHeight = self.graphDim.height; - if (self.options.verticalOrientation) { + if (options.verticalOrientation) { self.graphDim.height += enteringDomainDim - exitingDomainDim; } else { self.graphDim.width += enteringDomainDim - exitingDomainDim; } // At the time of exit, domainsWidth and domainsHeight already automatically shifted - domainSvg.exit().transition().duration(self.options.animationDuration) + domainSvg.exit().transition().duration(options.animationDuration) .attr("x", function(d){ - if (self.options.verticalOrientation) { + if (options.verticalOrientation) { return 0; } else { switch(navigationDir) { - case self.NAVIGATE_LEFT: return Math.min(self.graphDim.width, tempWidth); - case self.NAVIGATE_RIGHT: return -w(d, true); + case self.NAVIGATE_LEFT: + return Math.min(self.graphDim.width, tempWidth); + case self.NAVIGATE_RIGHT: + return -w(d, true); } } }) .attr("y", function(d){ - if (self.options.verticalOrientation) { + if (options.verticalOrientation) { switch(navigationDir) { - case self.NAVIGATE_LEFT: return Math.min(self.graphDim.height, tempHeight); - case self.NAVIGATE_RIGHT: return -h(d, true); + case self.NAVIGATE_LEFT: + return Math.min(self.graphDim.height, tempHeight); + case self.NAVIGATE_RIGHT: + return -h(d, true); } } else { return 0; @@ -1065,244 +1109,361 @@ var CalHeatMap = function() { // Resize the root container self.resize(); }; +}; + +CalHeatMap.prototype = { /** - * Fill the calendar by coloring the cells + * Validate and merge user settings with default settings * - * @param array svg An array of html node to apply the transformation to (optional) - * It's used to limit the painting to only a subset of the calendar - * @return void + * @param {object} settings User settings + * @return {bool} False if settings contains error */ - this.fill = function(svg) { - if (arguments.length === 0) { - svg = self.root.selectAll(".graph-domain"); - } - - var rect = svg - .selectAll("svg").selectAll("g") - .data(function(d) { return self._domains.get(d); }) - ; + /* jshint maxstatements:false */ + init: function(settings) { + "use strict"; - /** - * Colorize the cell via a style attribute if enabled - */ - function addStyle(element) { - if (self.legendScale === null) { - return false; - } + var parent = this; - element.attr("fill", function(d) { - if (d.v === 0 && self.options.legendColors !== null && self.options.legendColors.hasOwnProperty("empty")) { - return self.options.legendColors.empty; - } + parent.options = mergeRecursive(parent.options, settings); + var options = parent.options; - if (d.v < 0 && self.options.legend[0] > 0 && self.options.legendColors !== null && self.options.legendColors.hasOwnProperty("overflow")) { - return self.options.legendColors.overflow; - } + // Fatal errors + // Stop script execution on error + validateDomainType(); + validateSelector(options.itemSelector, false, "itemSelector"); - return self.legendScale(Math.min(d.v, self.options.legend[self.options.legend.length-2])); - }); + if (parent.allowedDataType.indexOf(options.dataType) < 0) { + throw new Error("The data type '" + options.dataType + "' is not valid data type"); } - rect.transition().duration(self.options.animationDuration).select("rect") - .attr("class", function(d) { - - var htmlClass = self.getHighlightClassName(d.t); - - if (self.legendScale === null) { - htmlClass += " graph-rect"; - } - - if (d.v !== null) { - htmlClass += " " + self.Legend.getClass(d.v, (self.legendScale === null)); - } else if (self.options.considerMissingDataAsZero) { - htmlClass += " " + self.Legend.getClass(0, (self.legendScale === null)); - } - - if (self.options.onClick !== null) { - htmlClass += " hover_cursor"; - } - - return htmlClass; - }) - .call(addStyle) - ; - - rect.transition().duration(self.options.animationDuration).select("title") - .text(function(d) { return self.getSubDomainTitle(d); }) - ; - }; - - this.init = function(settings) { - - self.options = mergeRecursive(self.options, settings); + if (d3.select(options.itemSelector)[0][0] === null) { + throw new Error("The node '" + options.itemSelector + "' specified in itemSelector does not exists"); + } - if (!this._domainType.hasOwnProperty(self.options.domain) || self.options.domain === "min" || self.options.domain.substring(0, 2) === "x_") { - console.log("The domain '" + self.options.domain + "' is not valid"); + try { + validateSelector(options.nextSelector, true, "nextSelector"); + validateSelector(options.previousSelector, true, "previousSelector"); + } catch(error) { + console.log(error.message); return false; } - if (!this._domainType.hasOwnProperty(self.options.subDomain) || self.options.subDomain === "year") { - console.log("The subDomain '" + self.options.subDomain + "' is not valid"); - return false; + // If other settings contains error, will fallback to default + + if (!settings.hasOwnProperty("subDomain")) { + this.options.subDomain = getOptimalSubDomain(settings.domain); } - if (this._domainType[self.options.domain].level <= this._domainType[self.options.subDomain].level) { - console.log("'" + self.options.subDomain + "' is not a valid subDomain to '" + self.options.domain + "'"); - return false; + if (typeof options.itemNamespace !== "string" || options.itemNamespace === "") { + console.log("itemNamespace can not be empty, falling back to cal-heatmap"); + options.itemNamespace = "cal-heatmap"; } - // Set the most suitable subdomain for the domain - // if subDomain is not explicitly specified - if (!settings.hasOwnProperty("subDomain")) { - switch(self.options.domain) { - case "year": self.options.subDomain = "month"; break; - case "month": self.options.subDomain = "day"; break; - case "week": self.options.subDomain = "day"; break; - case "day": self.options.subDomain = "hour"; break; - default: self.options.subDomain = "min"; + // Don't touch these settings + var s = ["data", "onComplete", "onClick", "afterLoad", "afterLoadData", "afterLoadPreviousDomain", "afterLoadNextDomain"]; + + for (var k in s) { + if (settings.hasOwnProperty(s[k])) { + options[s[k]] = settings[s[k]]; } } - if (allowedDataType.indexOf(self.options.dataType) < 0) { - console.log("The data type '" + self.options.dataType + "' is not valid data type"); - return false; + options.subDomainDateFormat = (typeof options.subDomainDateFormat === "string" || typeof options.subDomainDateFormat === "function" ? options.subDomainDateFormat : this._domainType[options.subDomain].format.date); + options.domainLabelFormat = (typeof options.domainLabelFormat === "string" || typeof options.domainLabelFormat === "function" ? options.domainLabelFormat : this._domainType[options.domain].format.legend); + options.subDomainTextFormat = ((typeof options.subDomainTextFormat === "string" && options.subDomainTextFormat !== "") || typeof options.subDomainTextFormat === "function" ? options.subDomainTextFormat : null); + options.domainMargin = expandMarginSetting(options.domainMargin); + options.legendMargin = expandMarginSetting(options.legendMargin); + options.highlight = parent.expandDateSetting(options.highlight); + options.itemName = expandItemName(options.itemName); + options.colLimit = parseColLimit(options.colLimit); + options.rowLimit = parseRowLimit(options.rowLimit); + if (!settings.hasOwnProperty("legendMargin")) { + autoAddLegendMargin(); } + autoAlignLabel(); - if (self.options.subDomainDateFormat === null) { - self.options.subDomainDateFormat = this._domainType[self.options.subDomain].format.date; + /** + * Validate that a queryString is valid + * + * @param {Element|string|bool} selector The queryString to test + * @param {bool} canBeFalse Whether false is an accepted and valid value + * @param {string} name Name of the tested selector + * @throws {Error} If the selector is not valid + * @return {bool} True if the selector is a valid queryString + */ + function validateSelector(selector, canBeFalse, name) { + if (((canBeFalse && selector === false) || selector instanceof Element || typeof selector === "string") && selector !== "") { + return true; + } + throw new Error("The " + name + " is not valid"); } - if (self.options.domainLabelFormat === null) { - self.options.domainLabelFormat = this._domainType[self.options.domain].format.legend; + /** + * Return the optimal subDomain for the specified domain + * + * @param {string} domain a domain name + * @return {string} the subDomain name + */ + function getOptimalSubDomain(domain) { + switch(domain) { + case "year": + return "month"; + case "month": + return "day"; + case "week": + return "day"; + case "day": + return "hour"; + default: + return "min"; + } } - // Auto-align label, depending on it's position - if (!settings.hasOwnProperty("label") || (settings.hasOwnProperty("label") && !settings.label.hasOwnProperty("align"))) { - switch(self.options.label.position) { - case "left": self.options.label.align = "right"; break; - case "right": self.options.label.align = "left"; break; - default: self.options.label.align = "center"; + /** + * Ensure that the domain and subdomain are valid + * + * @throw {Error} when domain or subdomain are not valid + * @return {bool} True if domain and subdomain are valid and compatible + */ + function validateDomainType() { + if (!parent._domainType.hasOwnProperty(options.domain) || options.domain === "min" || options.domain.substring(0, 2) === "x_") { + throw new Error("The domain '" + options.domain + "' is not valid"); } - if (self.options.label.rotate === "left") { - self.options.label.align = "right"; - } else if (self.options.label.rotate === "right") { - self.options.label.align = "left"; + if (!parent._domainType.hasOwnProperty(options.subDomain) || options.subDomain === "year") { + throw new Error("The subDomain '" + options.subDomain + "' is not valid"); } + if (parent._domainType[options.domain].level <= parent._domainType[options.subDomain].level) { + throw new Error("'" + options.subDomain + "' is not a valid subDomain to '" + options.domain + "'"); + } + + return true; } - if (!settings.hasOwnProperty("label") || (settings.hasOwnProperty("label") && !settings.label.hasOwnProperty("offset"))) { - if (self.options.label.position === "left" || self.options.label.position === "right") { - self.options.label.offset = { - x: 10, - y: 15 - }; + /** + * Fine-tune the label alignement depending on its position + * + * @return void + */ + function autoAlignLabel() { + // Auto-align label, depending on it's position + if (!settings.hasOwnProperty("label") || (settings.hasOwnProperty("label") && !settings.label.hasOwnProperty("align"))) { + switch(options.label.position) { + case "left": + options.label.align = "right"; + break; + case "right": + options.label.align = "left"; + break; + default: + options.label.align = "center"; + } + + if (options.label.rotate === "left") { + options.label.align = "right"; + } else if (options.label.rotate === "right") { + options.label.align = "left"; + } } - } - if (validateSelector(self.options.itemSelector)) { - console.log("The itemSelector is invalid"); - return false; + if (!settings.hasOwnProperty("label") || (settings.hasOwnProperty("label") && !settings.label.hasOwnProperty("offset"))) { + if (options.label.position === "left" || options.label.position === "right") { + options.label.offset = { + x: 10, + y: 15 + }; + } + } } - if (d3.select(self.options.itemSelector)[0][0] === null) { - console.log("The node specified in itemSelector does not exists"); - return false; + /** + * If not specified, add some margin around the legend depending on its position + * + * @return void + */ + function autoAddLegendMargin() { + switch(options.legendVerticalPosition) { + case "top": + options.legendMargin[2] = parent.DEFAULT_LEGEND_MARGIN; + break; + case "bottom": + options.legendMargin[0] = parent.DEFAULT_LEGEND_MARGIN; + break; + case "middle": + case "center": + options.legendMargin[options.legendHorizontalPosition === "right" ? 3 : 1] = parent.DEFAULT_LEGEND_MARGIN; + } } - if (self.options.nextSelector !== false && validateSelector(self.options.nextSelector)) { - console.log("The nextSelector is invalid"); - return false; - } + /** + * Expand a number of an array of numbers to an usable 4 values array + * + * @param {integer|array} value + * @return {array} array + */ + function expandMarginSetting(value) { + if (typeof value === "number") { + value = [value]; + } - if (self.options.previousSelector !== false && validateSelector(self.options.previousSelector)) { - console.log("The previousSelector is invalid"); - return false; - } + if (!Array.isArray(value)) { + console.log("Margin only takes an integer or an array of integers"); + value = [0]; + } - if (typeof self.options.itemNamespace !== "string" || self.options.itemNamespace === "") { - console.log("itemNamespace can not be empty, falling back to cal-heatmap"); - self.options.itemNamespace = "cal-heatmap"; + switch(value.length) { + case 0: + return [0, 0, 0, 0]; + case 1: + return [value[0], value[0], value[0], value[0]]; + case 2: + return [value[0], value[1], value[0], value[1]]; + case 3: + return [value[0], value[1], value[2], value[1]]; + case 4: + return value; + default: + return value.slice(0, 4); + } } - if (typeof self.options.domainMargin === "number") { - self.options.domainMargin = [self.options.domainMargin, self.options.domainMargin, self.options.domainMargin, self.options.domainMargin]; + /** + * Convert a string to an array like [singular-form, plural-form] + * + * @param {string|array} value Date to convert + * @return {array} An array like [singular-form, plural-form] + */ + function expandItemName(value) { + if (typeof value === "string") { + return [value, value + (value !== "" ? "s" : "")]; + } + + if (Array.isArray(value)) { + if (value.length === 1) { + return [value[0], value[0] + "s"]; + } else if (value.length > 2) { + return value.slice(0, 2); + } + + return value; + } + + return ["item", "items"]; } - if (settings.hasOwnProperty("rowLimit") && settings.hasOwnProperty("colLimit") && settings.rowLimit > 0 && settings.colLimit > 0) { - console.log("colLimit and rowLimit are mutually exclusive, rowLimit will be ignored"); - self.options.rowLimit = null; + function parseColLimit(value) { + return value > 0 ? value : null; } - if (Array.isArray(self.options.domainMargin)) { - switch(self.options.domainMargin.length) { - case 0: self.options.domainMargin = [0, 0, 0, 0]; break; - case 1: self.options.domainMargin = [self.options.domainMargin, self.options.domainMargin, self.options.domainMargin, self.options.domainMargin]; break; - case 2: self.options.domainMargin = [self.options.domainMargin[0], self.options.domainMargin[1], self.options.domainMargin[0], self.options.domainMargin[1]]; break; - case 3: self.options.domainMargin = [self.options.domainMargin[0], self.options.domainMargin[1], self.options.domainMargin[2], self.options.domainMargin[1]]; break; - case 4: self.options.domainMargin = self.options.domainMargin; break; - default: self.options.domainMargin.splice(4); + function parseRowLimit(value) { + if (value > 0 && options.colLimit > 0) { + console.log("colLimit and rowLimit are mutually exclusive, rowLimit will be ignored"); + return null; } + return value > 0 ? value : null; } - if (typeof self.options.itemName === "string") { - self.options.itemName = [self.options.itemName, self.options.itemName + "s"]; - } else if (Array.isArray(self.options.itemName) && self.options.itemName.length === 1) { - self.options.itemName = [self.options.itemName[0], self.options.itemName[0] + "s"]; - } + return this._init(); - // Don't touch these settings - var s = ["data", "onComplete", "onClick", "afterLoad", "afterLoadData", "afterLoadPreviousDomain", "afterLoadNextDomain"]; + }, - for (var k in s) { - if (settings.hasOwnProperty(s[k])) { - self.options[s[k]] = settings[s[k]]; - } + /** + * Convert a keyword or an array of keyword/date to an array of date objects + * + * @param {string|array|Date} value Data to convert + * @return {array} An array of Dates + */ + expandDateSetting: function(value) { + "use strict"; + + if (!Array.isArray(value)) { + value = [value]; } - if (typeof self.options.highlight === "string") { - if (self.options.highlight === "now") { - self.options.highlight = [new Date()]; - } else { - self.options.highlight = []; + return value.map(function(data) { + if (data === "now") { + return new Date(); } - } else if (Array.isArray(self.options.highlight)) { - var i = self.options.highlight.indexOf("now"); - if (i !== -1) { - self.options.highlight.splice(i, 1); - self.options.highlight.push(new Date()); + if (data instanceof Date) { + return data; } + return false; + }).filter(function(d) { return d !== false; }); + }, + + /** + * Fill the calendar by coloring the cells + * + * @param array svg An array of html node to apply the transformation to (optional) + * It's used to limit the painting to only a subset of the calendar + * @return void + */ + fill: function(svg) { + "use strict"; + + var parent = this; + var options = parent.options; + + if (arguments.length === 0) { + svg = parent.root.selectAll(".graph-domain"); } - if (!settings.hasOwnProperty("legendMargin")) { - if (self.options.legendVerticalPosition === "top") { - self.options.legendMargin[0] = self.DEFAULT_LEGEND_MARGIN; - } else if (self.options.legendVerticalPosition === "bottom") { - self.options.legendMargin[2] = self.DEFAULT_LEGEND_MARGIN; + var rect = svg + .selectAll("svg").selectAll("g") + .data(function(d) { return parent._domains.get(d); }) + ; + + /** + * Colorize the cell via a style attribute if enabled + */ + function addStyle(element) { + if (parent.legendScale === null) { + return false; } - if (self.options.legendHorizontalPosition === "middle" || self.options.legendHorizontalPosition === "center") { - if (self.options.legendVerticalPosition === "left") { - self.options.legendMargin[1] = self.DEFAULT_LEGEND_MARGIN; - } else if (self.options.legendVerticalPosition === "right") { - self.options.legendMargin[3] = self.DEFAULT_LEGEND_MARGIN; + element.attr("fill", function(d) { + if (d.v === 0 && options.legendColors !== null && options.legendColors.hasOwnProperty("empty")) { + return options.legendColors.empty; } - } - } + if (d.v < 0 && options.legend[0] > 0 && options.legendColors !== null && options.legendColors.hasOwnProperty("overflow")) { + return options.legendColors.overflow; + } - function validateSelector(selector) { - return ((!(selector instanceof Element) && typeof selector !== "string") || selector === ""); + return parent.legendScale(Math.min(d.v, options.legend[options.legend.length-2])); + }); } - return _init(); + rect.transition().duration(options.animationDuration).select("rect") + .attr("class", function(d) { + + var htmlClass = parent.getHighlightClassName(d.t); - }; -}; + if (parent.legendScale === null) { + htmlClass += " graph-rect"; + } + + if (d.v !== null) { + htmlClass += " " + parent.Legend.getClass(d.v, (parent.legendScale === null)); + } else if (options.considerMissingDataAsZero) { + htmlClass += " " + parent.Legend.getClass(0, (parent.legendScale === null)); + } + + if (options.onClick !== null) { + htmlClass += " hover_cursor"; + } + + return htmlClass; + }) + .call(addStyle) + ; -CalHeatMap.prototype = { + rect.transition().duration(options.animationDuration).select("title") + .text(function(d) { return parent.getSubDomainTitle(d); }) + ; + }, // =========================================================================// // EVENTS CALLBACK // @@ -1317,6 +1478,8 @@ CalHeatMap.prototype = { * @return mixed True when the triggering was skipped, false on error, else the callback function */ triggerEvent: function(eventName, successArgs, skip) { + "use strict"; + if ((arguments.length === 3 && skip) || this.options[eventName] === null) { return true; } @@ -1339,6 +1502,8 @@ CalHeatMap.prototype = { * @param int itemNb Number of items in that date */ onClick: function(d, itemNb) { + "use strict"; + return this.triggerEvent("onClick", [d, itemNb]); }, @@ -1346,6 +1511,8 @@ CalHeatMap.prototype = { * Event triggered after drawing the calendar, byt before filling it with data */ afterLoad: function() { + "use strict"; + return this.triggerEvent("afterLoad"); }, @@ -1353,6 +1520,8 @@ CalHeatMap.prototype = { * Event triggered after completing drawing and filling the calendar */ onComplete: function() { + "use strict"; + var response = this.triggerEvent("onComplete", [], this._completed); this._completed = true; return response; @@ -1365,6 +1534,8 @@ CalHeatMap.prototype = { * @param Date end Domain end date */ afterLoadPreviousDomain: function(start) { + "use strict"; + var parent = this; return this.triggerEvent("afterLoadPreviousDomain", function() { var subDomain = parent.getSubDomain(start); @@ -1379,6 +1550,8 @@ CalHeatMap.prototype = { * @param Date end Domain end date */ afterLoadNextDomain: function(start) { + "use strict"; + var parent = this; return this.triggerEvent("afterLoadNextDomain", function() { var subDomain = parent.getSubDomain(start); @@ -1392,6 +1565,8 @@ CalHeatMap.prototype = { * @param boolean reached True if the leftmost domain was reached */ onMinDomainReached: function(reached) { + "use strict"; + this._minDomainReached = reached; return this.triggerEvent("onMinDomainReached", [reached]); }, @@ -1402,10 +1577,40 @@ CalHeatMap.prototype = { * @param boolean reached True if the rightmost domain was reached */ onMaxDomainReached: function(reached) { + "use strict"; + this._maxDomainReached = reached; return this.triggerEvent("onMaxDomainReached", [reached]); }, + checkIfMinDomainIsReached: function(date, upperBound) { + "use strict"; + + if (this.minDomainIsReached(date)) { + this.onMinDomainReached(true); + } + + if (arguments.length === 2) { + if (this._maxDomainReached && !this.maxDomainIsReached(upperBound)) { + this.onMaxDomainReached(false); + } + } + }, + + checkIfMaxDomainIsReached: function(date, lowerBound) { + "use strict"; + + if (this.maxDomainIsReached(date)) { + this.onMaxDomainReached(true); + } + + if (arguments.length === 2) { + if (this._minDomainReached && !this.minDomainIsReached(lowerBound)) { + this.onMinDomainReached(false); + } + } + }, + // =========================================================================// // FORMATTER // // =========================================================================// @@ -1413,7 +1618,9 @@ CalHeatMap.prototype = { formatNumber: d3.format(",g"), formatDate: function(d, format) { - if (typeof format === "undefined") { + "use strict"; + + if (arguments.length < 2) { format = "title"; } @@ -1426,6 +1633,8 @@ CalHeatMap.prototype = { }, getSubDomainTitle: function(d) { + "use strict"; + if (d.v === null && !this.options.considerMissingDataAsZero) { return (this.options.subDomainTitleFormat.empty).format({ date: this.formatDate(new Date(d.t), this.options.subDomainDateFormat) @@ -1459,62 +1668,16 @@ CalHeatMap.prototype = { * @return bool True if the next domain was loaded, else false */ loadNextDomain: function(n) { + "use strict"; + if (this._maxDomainReached || n === 0) { return false; } - if (arguments.length === 0) { - n = 1; - } - - var newDomains = this.getDomain(this.getNextDomain(), n); - - var parent = this; - var i = -1; - var total = newDomains.length; - - // Appending new domains to existing domain list, as long as minDomain is not reached - while (++i < total) { - if (this.maxDomainIsReached(newDomains[i])) { - newDomains = newDomains.slice(0, i); - break; - } - this._domains.set( - newDomains[i].getTime(), - this.getSubDomain(newDomains[i]).map(function(d) { - return {t: parent._domainType[parent.options.subDomain].extractUnit(d), v: null}; - }) - ); - } - - var domains = this.getDomainKeys(); - - // Removing old domains - domains.slice(0, newDomains.length).forEach(function(key) { - parent._domains.remove(key); - }); - - this.paint(this.NAVIGATE_RIGHT); - - this.getDatas( - this.options.data, - newDomains[0], - this.getSubDomain(newDomains[newDomains.length-1]).pop(), - function() { - parent.fill(parent.lastInsertedSvg); - } - ); - - this.afterLoadNextDomain(newDomains[newDomains.length-1]); + var bound = this.loadNewDomains(this.NAVIGATE_RIGHT, this.getDomain(this.getNextDomain(), n)); - if (this.maxDomainIsReached(this.getNextDomain().getTime())) { - this.onMaxDomainReached(true); - } - - // Try to "disengage" the min domain reached setting - if (this._minDomainReached && !this.minDomainIsReached(domains[1])) { - this.onMinDomainReached(false); - } + this.afterLoadNextDomain(bound.end); + this.checkIfMaxDomainIsReached(this.getNextDomain().getTime(), bound.start); return true; }, @@ -1528,47 +1691,63 @@ CalHeatMap.prototype = { * @return bool True if the previous domain was loaded, else false */ loadPreviousDomain: function(n) { + "use strict"; + if (this._minDomainReached || n === 0) { return false; } - if (arguments.length === 0) { - n = 1; - } + var bound = this.loadNewDomains(this.NAVIGATE_LEFT, this.getDomain(this.getDomainKeys()[0], -n).reverse()); - var domains = this.getDomainKeys(); - var newDomains = this.getDomain(domains[0], -n).reverse(); + this.afterLoadPreviousDomain(bound.start); + this.checkIfMinDomainIsReached(bound.start, bound.end); + + return true; + }, + + loadNewDomains: function(direction, newDomains) { + "use strict"; var parent = this; + var backward = direction === this.NAVIGATE_LEFT; var i = -1; var total = newDomains.length; + var domains = this.getDomainKeys(); + + function buildSubDomain(d) { + return {t: parent._domainType[parent.options.subDomain].extractUnit(d), v: null}; + } // Remove out of bound domains from list of new domains to prepend while (++i < total) { - if (this.minDomainIsReached(newDomains[i])) { + if (backward && this.minDomainIsReached(newDomains[i])) { newDomains = newDomains.slice(0, i+1); break; } + if (!backward && this.maxDomainIsReached(newDomains[i])) { + newDomains = newDomains.slice(0, i); + break; + } } + newDomains = newDomains.slice(-this.options.range); + for (i = 0, total = newDomains.length; i < total; i++) { - parent._domains.set( + this._domains.set( newDomains[i].getTime(), - parent.getSubDomain(newDomains[i]).map(function(d) { - return {t: parent._domainType[parent.options.subDomain].extractUnit(d), v: null}; - }) + this.getSubDomain(newDomains[i]).map(buildSubDomain) ); + + this._domains.remove(backward ? domains.pop() : domains.shift()); } domains = this.getDomainKeys(); - domains.slice(-newDomains.length).forEach(function(key) { - parent._domains.remove(key); - }); - - newDomains = newDomains.reverse(); + if (backward) { + newDomains = newDomains.reverse(); + } - this.paint(this.NAVIGATE_LEFT); + this.paint(direction); this.getDatas( this.options.data, @@ -1579,18 +1758,10 @@ CalHeatMap.prototype = { } ); - this.afterLoadPreviousDomain(newDomains[0]); - - if (this.minDomainIsReached(newDomains[0])) { - this.onMinDomainReached(true); - } - - // Try to "disengage" the max domain reached setting - if (this._maxDomainReached && !this.maxDomainIsReached(domains[domains.length-1])) { - this.onMaxDomainReached(false); - } - - return true; + return { + start: newDomains[backward ? 0 : 1], + end: domains[domains.length-1] + }; }, /** @@ -1600,6 +1771,8 @@ CalHeatMap.prototype = { * @return bool True if the specified date correspond to the calendar upper bound */ maxDomainIsReached: function(datetimestamp) { + "use strict"; + return (this.options.maxDate !== null && (this.options.maxDate.getTime() < datetimestamp)); }, @@ -1610,6 +1783,8 @@ CalHeatMap.prototype = { * @return bool True if the specified date correspond to the calendar lower bound */ minDomainIsReached: function (datetimestamp) { + "use strict"; + return (this.options.minDate !== null && (this.options.minDate.getTime() >= datetimestamp)); }, @@ -1619,6 +1794,8 @@ CalHeatMap.prototype = { * @return Array a sorted array of timestamp */ getDomainKeys: function() { + "use strict"; + return this._domains.keys() .map(function(d) { return parseInt(d, 10); }) .sort(function(a,b) { return a-b; }); @@ -1629,11 +1806,15 @@ CalHeatMap.prototype = { // =========================================================================// positionSubDomainX: function(d) { + "use strict"; + var index = this._domainType[this.options.subDomain].position.x(new Date(d)); return index * this.options.cellSize + index * this.options.cellPadding; }, positionSubDomainY: function(d) { + "use strict"; + var index = this._domainType[this.options.subDomain].position.y(new Date(d)); return index * this.options.cellSize + index * this.options.cellPadding; }, @@ -1644,8 +1825,9 @@ CalHeatMap.prototype = { * @param timestamp date Date of the current subDomain * @return String the highlight class */ - getHighlightClassName: function(d) - { + getHighlightClassName: function(d) { + "use strict"; + d = new Date(d); if (this.options.highlight.length > 0) { @@ -1666,6 +1848,8 @@ CalHeatMap.prototype = { * @return bool True if the date correspond to a subdomain cell */ isNow: function(d) { + "use strict"; + return this.dateIsEqual(d, new Date()); }, @@ -1674,37 +1858,41 @@ CalHeatMap.prototype = { * This function is subdomain-aware, * and dates comparison are dependent of the subdomain * - * @param Date date_a First date to compare - * @param Date date_b Secon date to compare + * @param Date dateA First date to compare + * @param Date dateB Secon date to compare * @return bool true if the 2 dates are equals */ - dateIsEqual: function(date_a, date_b) { + /* jshint maxcomplexity: false */ + dateIsEqual: function(dateA, dateB) { + "use strict"; + switch(this.options.subDomain) { - case "x_min": - case "min": - return date_a.getFullYear() === date_b.getFullYear() && - date_a.getMonth() === date_b.getMonth() && - date_a.getDate() === date_b.getDate() && - date_a.getHours() === date_b.getHours() && - date_a.getMinutes() === date_b.getMinutes(); - case "x_hour": - case "hour": - return date_a.getFullYear() === date_b.getFullYear() && - date_a.getMonth() === date_b.getMonth() && - date_a.getDate() === date_b.getDate() && - date_a.getHours() === date_b.getHours(); - case "x_day": - case "day": - return date_a.getFullYear() === date_b.getFullYear() && - date_a.getMonth() === date_b.getMonth() && - date_a.getDate() === date_b.getDate(); - case "x_week": - case "week": - case "x_month": - case "month": - return date_a.getFullYear() === date_b.getFullYear() && - date_a.getMonth() === date_b.getMonth(); - default: return false; + case "x_min": + case "min": + return dateA.getFullYear() === dateB.getFullYear() && + dateA.getMonth() === dateB.getMonth() && + dateA.getDate() === dateB.getDate() && + dateA.getHours() === dateB.getHours() && + dateA.getMinutes() === dateB.getMinutes(); + case "x_hour": + case "hour": + return dateA.getFullYear() === dateB.getFullYear() && + dateA.getMonth() === dateB.getMonth() && + dateA.getDate() === dateB.getDate() && + dateA.getHours() === dateB.getHours(); + case "x_day": + case "day": + return dateA.getFullYear() === dateB.getFullYear() && + dateA.getMonth() === dateB.getMonth() && + dateA.getDate() === dateB.getDate(); + case "x_week": + case "week": + case "x_month": + case "month": + return dateA.getFullYear() === dateB.getFullYear() && + dateA.getMonth() === dateB.getMonth(); + default: + return false; } }, @@ -1725,6 +1913,8 @@ CalHeatMap.prototype = { * @return int Week number [0-53] */ getWeekNumber: function(d) { + "use strict"; + var f = this.options.weekStartOnMonday === true ? d3.time.format("%W"): d3.time.format("%U"); return f(d); }, @@ -1736,6 +1926,8 @@ CalHeatMap.prototype = { * @return int Week number, relative to the month [0-5] */ getMonthWeekNumber: function (d) { + "use strict"; + if (typeof d === "number") { d = new Date(d); } @@ -1751,6 +1943,8 @@ CalHeatMap.prototype = { * @return int Number of weeks in the date's year */ getWeekNumberInYear: function(d) { + "use strict"; + if (typeof d === "number") { d = new Date(d); } @@ -1763,6 +1957,8 @@ CalHeatMap.prototype = { * @return int Number of days in the date's month */ getDayCountInMonth: function(d) { + "use strict"; + return this.getEndOfMonth(d).getDate(); }, @@ -1773,6 +1969,8 @@ CalHeatMap.prototype = { * @return int Number of days in the date's year */ getDayCountInYear: function(d) { + "use strict"; + if (typeof d === "number") { d = new Date(d); } @@ -1789,6 +1987,8 @@ CalHeatMap.prototype = { * @return int The week day number (0-6) */ getWeekDay: function(d) { + "use strict"; + if (this.options.weekStartOnMonday === false) { return d.getDay(); } @@ -1801,6 +2001,8 @@ CalHeatMap.prototype = { * @return Date Last day of the month */ getEndOfMonth: function(d) { + "use strict"; + if (typeof d === "number") { d = new Date(d); } @@ -1815,13 +2017,24 @@ CalHeatMap.prototype = { * @return Date */ jumpDate: function(date, count, step) { + "use strict"; + var d = new Date(date); switch(step) { - case "hour" : d.setHours(d.getHours() + count); break; - case "day" : d.setHours(d.getHours() + count * 24); break; - case "week" : d.setHours(d.getHours() + count * 24 * 7); break; - case "month" : d.setMonth(d.getMonth() + count); break; - case "year" : d.setFullYear(d.getFullYear() + count); + case "hour": + d.setHours(d.getHours() + count); + break; + case "day": + d.setHours(d.getHours() + count * 24); + break; + case "week": + d.setHours(d.getHours() + count * 24 * 7); + break; + case "month": + d.setMonth(d.getMonth() + count); + break; + case "year": + d.setFullYear(d.getFullYear() + count); } return new Date(d); @@ -1839,9 +2052,11 @@ CalHeatMap.prototype = { * @return array An array of minutes */ getMinuteDomain: function (d, range) { + "use strict"; + var start = new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours()); var stop = null; - if (typeof range === "object") { + if (range instanceof Date) { stop = new Date(range.getFullYear(), range.getMonth(), range.getDate(), range.getHours()); } else { stop = new Date(start.getTime() + 60 * 1000 * range); @@ -1858,9 +2073,11 @@ CalHeatMap.prototype = { * @return array An array of hours */ getHourDomain: function (d, range) { + "use strict"; + var start = new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours()); var stop = null; - if (typeof range === "object") { + if (range instanceof Date) { stop = new Date(range.getFullYear(), range.getMonth(), range.getDate(), range.getHours()); } else { stop = new Date(start.getTime() + 3600 * 1000 * range); @@ -1877,9 +2094,11 @@ CalHeatMap.prototype = { * @return array An array of weeks */ getDayDomain: function (d, range) { + "use strict"; + var start = new Date(d.getFullYear(), d.getMonth(), d.getDate()); var stop = null; - if (typeof range === "object") { + if (range instanceof Date) { stop = new Date(range.getFullYear(), range.getMonth(), range.getDate()); } else { stop = new Date(start); @@ -1897,6 +2116,8 @@ CalHeatMap.prototype = { * @return array An array of weeks */ getWeekDomain: function (d, range) { + "use strict"; + var weekStart; if (this.options.weekStartOnMonday === false) { @@ -1933,9 +2154,11 @@ CalHeatMap.prototype = { * @return array An array of months */ getMonthDomain: function (d, range) { + "use strict"; + var start = new Date(d.getFullYear(), d.getMonth()); var stop = null; - if (typeof range === "object") { + if (range instanceof Date) { stop = new Date(range.getFullYear(), range.getMonth()); } else { stop = new Date(start); @@ -1953,9 +2176,11 @@ CalHeatMap.prototype = { * @return array An array of hours */ getYearDomain: function(d, range){ + "use strict"; + var start = new Date(d.getFullYear(), 0); var stop = null; - if (typeof range === "object") { + if (range instanceof Date) { stop = new Date(range.getFullYear(), 0); } else { stop = new Date(d.getFullYear()+range, 0); @@ -1972,6 +2197,8 @@ CalHeatMap.prototype = { * @return Array of dates */ getDomain: function(date, range) { + "use strict"; + if (typeof date === "number") { date = new Date(date); } @@ -1981,15 +2208,23 @@ CalHeatMap.prototype = { } switch(this.options.domain) { - case "hour" : return this.getHourDomain(date, range); - case "day" : return this.getDayDomain(date, range); - case "week" : return this.getWeekDomain(date, range); - case "month": return this.getMonthDomain(date, range); - case "year" : return this.getYearDomain(date, range); + case "hour" : + return this.getHourDomain(date, range); + case "day" : + return this.getDayDomain(date, range); + case "week" : + return this.getWeekDomain(date, range); + case "month": + return this.getMonthDomain(date, range); + case "year" : + return this.getYearDomain(date, range); } }, + /* jshint maxcomplexity: false */ getSubDomain: function(date) { + "use strict"; + if (typeof date === "number") { date = new Date(date); } @@ -2001,9 +2236,12 @@ CalHeatMap.prototype = { */ var computeDaySubDomainSize = function(date, domain) { switch(domain) { - case "year": return parent.getDayCountInYear(date); - case "month": return parent.getDayCountInMonth(date); - case "week": return 7; + case "year": + return parent.getDayCountInYear(date); + case "month": + return parent.getDayCountInMonth(date); + case "week": + return 7; } }; @@ -2012,9 +2250,12 @@ CalHeatMap.prototype = { */ var computeMinSubDomainSize = function(date, domain) { switch (domain) { - case "hour": return 60; - case "day": return 60 * 24; - case "week": return 60 * 24 * 7; + case "hour": + return 60; + case "day": + return 60 * 24; + case "week": + return 60 * 24 * 7; } }; @@ -2023,9 +2264,12 @@ CalHeatMap.prototype = { */ var computeHourSubDomainSize = function(date, domain) { switch(domain) { - case "day": return 24; - case "week": return 168; - case "month": return parent.getDayCountInMonth(date) * 24; + case "day": + return 24; + case "week": + return 168; + case "month": + return parent.getDayCountInMonth(date) * 24; } }; @@ -2050,16 +2294,21 @@ CalHeatMap.prototype = { }; switch(this.options.subDomain) { - case "x_min": - case "min" : return this.getMinuteDomain(date, computeMinSubDomainSize(date, this.options.domain)); - case "x_hour": - case "hour" : return this.getHourDomain(date, computeHourSubDomainSize(date, this.options.domain)); - case "x_day": - case "day" : return this.getDayDomain(date, computeDaySubDomainSize(date, this.options.domain)); - case "x_week": - case "week" : return this.getWeekDomain(date, computeWeekSubDomainSize(date, this.options.domain)); - case "x_month": - case "month": return this.getMonthDomain(date, 12); + case "x_min": + case "min" : + return this.getMinuteDomain(date, computeMinSubDomainSize(date, this.options.domain)); + case "x_hour": + case "hour" : + return this.getHourDomain(date, computeHourSubDomainSize(date, this.options.domain)); + case "x_day": + case "day" : + return this.getDayDomain(date, computeDaySubDomainSize(date, this.options.domain)); + case "x_week": + case "week" : + return this.getWeekDomain(date, computeWeekSubDomainSize(date, this.options.domain)); + case "x_month": + case "month": + return this.getMonthDomain(date, 12); } }, @@ -2069,6 +2318,8 @@ CalHeatMap.prototype = { * @return Date The start date of the wanted domain */ getNextDomain: function(n) { + "use strict"; + if (arguments.length === 0) { n = 1; } @@ -2081,6 +2332,8 @@ CalHeatMap.prototype = { * @return Date The start date of the wanted domain */ getPreviousDomain: function(n) { + "use strict"; + if (arguments.length === 0) { n = 1; } @@ -2107,6 +2360,8 @@ CalHeatMap.prototype = { * - False if data are loaded asynchronously */ getDatas: function(source, startDate, endDate, callback, afterLoad, updateMode) { + "use strict"; + var self = this; if (arguments.length < 5) { afterLoad = true; @@ -2122,46 +2377,49 @@ CalHeatMap.prototype = { data = self.options.afterLoadData(data); } else { console.log("Provided callback for afterLoadData is not a function."); - return {}; } + } else if (self.options.dataType === "csv" || self.options.dataType === "tsv") { + data = this.interpretCSV(data); } self.parseDatas(data, updateMode, startDate, endDate); - callback(); + if (typeof callback === "function") { + callback(); + } }; switch(typeof source) { - case "string": - if (source === "") { - _callback({}); - return true; - } else { - switch(this.options.dataType) { - case "json": - d3.json(this.parseURI(source, startDate, endDate), _callback); - break; - case "csv": - d3.csv(this.parseURI(source, startDate, endDate), _callback); - break; - case "tsv": - d3.tsv(this.parseURI(source, startDate, endDate), _callback); - break; - case "text": - d3.text(this.parseURI(source, startDate, endDate), "text/plain", _callback); - break; - } - - return false; - } - break; - case "object": - // Check that source is really a valid json object - if (source === Object(source) && Object.prototype.toString.call(source) !== "[object Array]") { - _callback(source); - return false; + case "string": + if (source === "") { + _callback({}); + return true; + } else { + switch(this.options.dataType) { + case "json": + d3.json(this.parseURI(source, startDate, endDate), _callback); + break; + case "csv": + d3.csv(this.parseURI(source, startDate, endDate), _callback); + break; + case "tsv": + d3.tsv(this.parseURI(source, startDate, endDate), _callback); + break; + case "txt": + d3.text(this.parseURI(source, startDate, endDate), "text/plain", _callback); + break; } + } + return false; + case "object": + // Check that source is really a valid json object + if (source === Object(source) && Object.prototype.toString.call(source) !== "[object Array]") { + _callback(source); + return false; + } + /* falls through */ + default: + _callback({}); + return true; } - - return true; }, /** @@ -2175,6 +2433,7 @@ CalHeatMap.prototype = { * @return void */ parseDatas: function(data, updateMode, startDate, endDate) { + "use strict"; if (updateMode === this.RESET_ALL_ON_UPDATE) { this._domains.forEach(function(key, value) { @@ -2187,33 +2446,35 @@ CalHeatMap.prototype = { var domainKeys = this._domains.keys(); var subDomainStep = this._domains.get(domainKeys[0])[1].t - this._domains.get(domainKeys[0])[0].t; + /*jshint forin:false */ for (var d in data) { - if (isNaN(d)) { - continue; - } var date = new Date(d*1000); var domainUnit = this.getDomain(date)[0].getTime(); - // Record only datas relevant to the current domain - if (this._domains.has(domainUnit) && (domainUnit >= +startDate && domainUnit < +endDate)) { - var subDomainUnit = this._domainType[this.options.subDomain].extractUnit(date); - var subDomainsData = this._domains.get(domainUnit); - var index = Math.round((subDomainUnit - domainUnit) / subDomainStep); + // Skip if data is not relevant to current domain + if (isNaN(d) || !data.hasOwnProperty(d) || !this._domains.has(domainUnit) || !(domainUnit >= +startDate && domainUnit < +endDate)) { + continue; + } + + var subDomainUnit = this._domainType[this.options.subDomain].extractUnit(date); + var subDomainsData = this._domains.get(domainUnit); + var index = Math.round((subDomainUnit - domainUnit) / subDomainStep); - if (updateMode === this.RESET_SINGLE_ON_UPDATE) { - subDomainsData[index].v = data[d]; + if (updateMode === this.RESET_SINGLE_ON_UPDATE) { + subDomainsData[index].v = data[d]; + } else { + if (!isNaN(subDomainsData[index].v)) { + subDomainsData[index].v += data[d]; } else { - if (!isNaN(subDomainsData[index].v)) { - subDomainsData[index].v += data[d]; - } else { - subDomainsData[index].v = data[d]; - } + subDomainsData[index].v = data[d]; } } } }, parseURI: function(str, startDate, endDate) { + "use strict"; + // Use a timestamp in seconds str = str.replace(/\{\{t:start\}\}/g, startDate.getTime()/1000); str = str.replace(/\{\{t:end\}\}/g, endDate.getTime()/1000); @@ -2225,6 +2486,18 @@ CalHeatMap.prototype = { return str; }, + interpretCSV: function(data) { + "use strict"; + + var d = {}; + var keys = Object.keys(data[0]); + var i, total; + for (i = 0, total = data.length; i < total; i++) { + d[data[i][keys[0]]] = +data[i][keys[1]]; + } + return d; + }, + /** * Handle the calendar layout and dimension * @@ -2235,40 +2508,43 @@ CalHeatMap.prototype = { * @return void */ resize: function() { + "use strict"; + var parent = this; - var legendWidth = parent.options.displayLegend ? (parent.Legend.getDim("width") + parent.options.legendMargin[1] + parent.options.legendMargin[3]) : 0; - var legendHeight = parent.options.displayLegend ? (parent.Legend.getDim("height") + parent.options.legendMargin[0] + parent.options.legendMargin[2]) : 0; + var options = parent.options; + var legendWidth = options.displayLegend ? (parent.Legend.getDim("width") + options.legendMargin[1] + options.legendMargin[3]) : 0; + var legendHeight = options.displayLegend ? (parent.Legend.getDim("height") + options.legendMargin[0] + options.legendMargin[2]) : 0; - var graphWidth = parent.graphDim.width - parent.options.domainGutter - parent.options.cellPadding; - var graphHeight = parent.graphDim.height - parent.options.domainGutter - parent.options.cellPadding; + var graphWidth = parent.graphDim.width - options.domainGutter - options.cellPadding; + var graphHeight = parent.graphDim.height - options.domainGutter - options.cellPadding; - this.root.transition().duration(parent.options.animationDuration) + this.root.transition().duration(options.animationDuration) .attr("width", function() { - if (parent.options.legendVerticalPosition === "middle" || parent.options.legendVerticalPosition === "center") { + if (options.legendVerticalPosition === "middle" || options.legendVerticalPosition === "center") { return graphWidth + legendWidth; } return Math.max(graphWidth, legendWidth); }) .attr("height", function() { - if (parent.options.legendVerticalPosition === "middle" || parent.options.legendVerticalPosition === "center") { + if (options.legendVerticalPosition === "middle" || options.legendVerticalPosition === "center") { return Math.max(graphHeight, legendHeight); } return graphHeight + legendHeight; }) ; - this.root.select(".graph").transition().duration(parent.options.animationDuration) + this.root.select(".graph").transition().duration(options.animationDuration) .attr("y", function() { - if (parent.options.legendVerticalPosition === "top") { + if (options.legendVerticalPosition === "top") { return legendHeight; } return 0; }) .attr("x", function() { if ( - (parent.options.legendVerticalPosition === "middle" || parent.options.legendVerticalPosition === "center") && - parent.options.legendHorizontalPosition === "left") { - return legendWidth; + (options.legendVerticalPosition === "middle" || options.legendVerticalPosition === "center") && + options.legendHorizontalPosition === "left") { + return legendWidth; } return 0; @@ -2284,6 +2560,8 @@ CalHeatMap.prototype = { * Shift the calendar forward */ next: function(n) { + "use strict"; + if (arguments.length === 0) { n = 1; } @@ -2294,6 +2572,8 @@ CalHeatMap.prototype = { * Shift the calendar backward */ previous: function(n) { + "use strict"; + if (arguments.length === 0) { n = 1; } @@ -2312,6 +2592,8 @@ CalHeatMap.prototype = { * @param bool True of the calendar was scrolled */ jumpTo: function(date, reset) { + "use strict"; + if (arguments.length < 2) { reset = false; } @@ -2342,6 +2624,8 @@ CalHeatMap.prototype = { * if you don't want to use the afterLoad() callback */ update: function(dataSource, afterLoad, updateMode) { + "use strict"; + if (arguments.length < 2) { afterLoad = true; } @@ -2370,6 +2654,8 @@ CalHeatMap.prototype = { * @param array colorRange an array of 2 hex colors, for the minimum and maximum colors */ setLegend: function() { + "use strict"; + var oldLegend = this.options.legend.slice(0); if (arguments.length >= 1 && Array.isArray(arguments[0])) { this.options.legend = arguments[0]; @@ -2380,7 +2666,6 @@ CalHeatMap.prototype = { } else { this.options.legendColors = arguments[1]; } - } if ((arguments.length > 0 && !arrayEquals(oldLegend, this.options.legend)) || arguments.length >= 2) { @@ -2388,9 +2673,7 @@ CalHeatMap.prototype = { this.fill(); } - if (this.options.displayLegend) { - this.Legend.redraw(this.graphDim.width - this.options.domainGutter - this.options.cellPadding); - } + this.Legend.redraw(this.graphDim.width - this.options.domainGutter - this.options.cellPadding); }, /** @@ -2399,6 +2682,8 @@ CalHeatMap.prototype = { * @return bool False if there is no legend to remove */ removeLegend: function() { + "use strict"; + if (!this.options.displayLegend) { return false; } @@ -2413,6 +2698,8 @@ CalHeatMap.prototype = { * @return bool False if the legend was already displayed */ showLegend: function() { + "use strict"; + if (this.options.displayLegend) { return false; } @@ -2421,7 +2708,19 @@ CalHeatMap.prototype = { return true; }, + highlight: function(args) { + "use strict"; + + if ((this.options.highlight = this.expandDateSetting(args)) !== []) { + this.fill(); + return true; + } + return false; + }, + getSVG: function() { + "use strict"; + var styles = { ".graph": {}, ".graph-rect": {}, @@ -2463,7 +2762,11 @@ CalHeatMap.prototype = { return root.select(e)[0][0]; }; + /* jshint forin:false */ for (var element in styles) { + if (!styles.hasOwnProperty(element)) { + continue; + } var dom = getElement(element); @@ -2471,7 +2774,9 @@ CalHeatMap.prototype = { continue; } - // The DOM Level 2 CSS way + // The DOM Level 2 CSS wa + // y + /* jshint maxdepth: false */ if ("getComputedStyle" in window) { var cs = getComputedStyle(dom, null); if (cs.length !== 0) { @@ -2526,28 +2831,40 @@ CalHeatMap.prototype = { * Compute the position of a domain, relative to the calendar */ var DomainPosition = function() { + "use strict"; + this.positions = d3.map(); }; DomainPosition.prototype.getPosition = function(d) { + "use strict"; + return this.positions.get(d); }; DomainPosition.prototype.getPositionFromIndex = function(i) { + "use strict"; + var domains = this.getKeys(); return this.positions.get(domains[i]); }; DomainPosition.prototype.getLast = function() { + "use strict"; + var domains = this.getKeys(); return this.positions.get(domains[domains.length-1]); }; DomainPosition.prototype.setPosition = function(d, dim) { + "use strict"; + this.positions.set(d, dim); }; DomainPosition.prototype.shiftRightBy = function(exitingDomainDim) { + "use strict"; + this.positions.forEach(function(key, value) { this.set(key, value - exitingDomainDim); }); @@ -2557,6 +2874,8 @@ DomainPosition.prototype.shiftRightBy = function(exitingDomainDim) { }; DomainPosition.prototype.shiftLeftBy = function(enteringDomainDim) { + "use strict"; + this.positions.forEach(function(key, value) { this.set(key, value + enteringDomainDim); }); @@ -2566,6 +2885,8 @@ DomainPosition.prototype.shiftLeftBy = function(enteringDomainDim) { }; DomainPosition.prototype.getKeys = function() { + "use strict"; + return this.positions.keys().sort(function(a, b) { return parseInt(a, 10) - parseInt(b, 10); }); @@ -2576,6 +2897,8 @@ DomainPosition.prototype.getKeys = function() { // =========================================================================// var Legend = function(calendar) { + "use strict"; + this.calendar = calendar; this.computeDim(); @@ -2585,34 +2908,41 @@ var Legend = function(calendar) { }; Legend.prototype.computeDim = function() { - /* - 1 extra pixel is added to the width and height - to avoid the stroke displayed on hover clipped on webkit - */ + "use strict"; + + var options = this.calendar.options; // Shorter accessor for variable name mangling when minifying this.dim = { width: - this.calendar.options.legendCellSize * (this.calendar.options.legend.length+1) + - this.calendar.options.legendCellPadding * (this.calendar.options.legend.length) + 1, + options.legendCellSize * (options.legend.length+1) + + options.legendCellPadding * (options.legend.length), height: - this.calendar.options.legendCellSize + 1 + options.legendCellSize }; }; Legend.prototype.remove = function() { + "use strict"; + this.calendar.root.select(".graph-legend").remove(); this.calendar.resize(); }; Legend.prototype.redraw = function(width) { + "use strict"; + + if (!this.calendar.options.displayLegend) { + return false; + } var parent = this; var calendar = this.calendar; var legend = calendar.root; var legendItem; + var options = calendar.options; // Shorter accessor for variable name mangling when minifying this.computeDim(); - var _legend = calendar.options.legend.slice(0); + var _legend = options.legend.slice(0); _legend.push(_legend[_legend.length-1]+1); var legendElement = calendar.root.select(".graph-legend"); @@ -2624,11 +2954,7 @@ Legend.prototype.redraw = function(width) { ; } else { // Creating the new legend DOM if it doesn't already exist - if (calendar.options.legendVerticalPosition === "top") { - legend = legend.insert("svg", ".graph"); - } else { - legend = legend.append("svg"); - } + legend = options.legendVerticalPosition === "top" ? legend.insert("svg", ".graph") : legend.append("svg"); legend .attr("x", getLegendXPosition()) @@ -2651,18 +2977,18 @@ Legend.prototype.redraw = function(width) { .attr("class", function(d){ return calendar.Legend.getClass(d, (calendar.legendScale === null)); }) .attr("fill-opacity", 0) .call(function(selection) { - if (calendar.legendScale !== null && calendar.options.legendColors !== null && calendar.options.legendColors.hasOwnProperty("base")) { - selection.attr("fill", calendar.options.legendColors.base); + if (calendar.legendScale !== null && options.legendColors !== null && options.legendColors.hasOwnProperty("base")) { + selection.attr("fill", options.legendColors.base); } }) .append("title") ; - legendItem.exit().transition().duration(calendar.options.animationDuration) + legendItem.exit().transition().duration(options.animationDuration) .attr("fill-opacity", 0) .remove(); - legendItem.transition().delay(function(d, i) { return calendar.options.animationDuration * i/10; }) + legendItem.transition().delay(function(d, i) { return options.animationDuration * i/10; }) .call(legendCellLayout) .attr("fill-opacity", 1) .call(function(element) { @@ -2674,7 +3000,7 @@ Legend.prototype.redraw = function(width) { if (i === 0) { return calendar.legendScale(d - 1); } - return calendar.legendScale(calendar.options.legend[i-1]); + return calendar.legendScale(options.legend[i-1]); }); element.attr("class", function(d) { return calendar.Legend.getClass(d, (calendar.legendScale === null)); }); @@ -2683,67 +3009,74 @@ Legend.prototype.redraw = function(width) { function legendCellLayout(selection) { selection - .attr("width", calendar.options.legendCellSize) - .attr("height", calendar.options.legendCellSize) + .attr("width", options.legendCellSize) + .attr("height", options.legendCellSize) .attr("x", function(d, i) { - return i * (calendar.options.legendCellSize + calendar.options.legendCellPadding); + return i * (options.legendCellSize + options.legendCellPadding); }) ; } legendItem.select("title").text(function(d, i) { - if (i === 0) { - return (calendar.options.legendTitleFormat.lower).format({ - min: calendar.options.legend[i], - name: calendar.options.itemName[1]}); - } else if (i === _legend.length-1) { - return (calendar.options.legendTitleFormat.upper).format({ - max: calendar.options.legend[i-1], - name: calendar.options.itemName[1]}); - } else { - return (calendar.options.legendTitleFormat.inner).format({ - down: calendar.options.legend[i-1], - up: calendar.options.legend[i], - name: calendar.options.itemName[1]}); - } - }) + if (i === 0) { + return (options.legendTitleFormat.lower).format({ + min: options.legend[i], + name: options.itemName[1] + }); + } else if (i === _legend.length-1) { + return (options.legendTitleFormat.upper).format({ + max: options.legend[i-1], + name: options.itemName[1] + }); + } else { + return (options.legendTitleFormat.inner).format({ + down: options.legend[i-1], + up: options.legend[i], + name: options.itemName[1] + }); + } + }) ; - legend.transition().duration(calendar.options.animationDuration) + legend.transition().duration(options.animationDuration) .attr("x", getLegendXPosition()) .attr("y", getLegendYPosition()) .attr("width", parent.getDim("width")) .attr("height", parent.getDim("height")) ; - legend.select("g").transition().duration(calendar.options.animationDuration) + legend.select("g").transition().duration(options.animationDuration) .attr("transform", function() { - if (calendar.options.legendOrientation === "vertical") { - return "rotate(90 " + calendar.options.legendCellSize/2 + " " + calendar.options.legendCellSize/2 + ")"; + if (options.legendOrientation === "vertical") { + return "rotate(90 " + options.legendCellSize/2 + " " + options.legendCellSize/2 + ")"; } return ""; }) ; function getLegendXPosition() { - switch(calendar.options.legendHorizontalPosition) { - case "right": - if (calendar.options.legendVerticalPosition === "center" || calendar.options.legendVerticalPosition === "middle") { - return width + calendar.options.legendMargin[3]; - } - return width - parent.getDim("width") - calendar.options.legendMargin[1]; - case "middle": - case "center": return Math.round(width/2 - parent.getDim("width")/2); - default: return calendar.options.legendMargin[3]; + switch(options.legendHorizontalPosition) { + case "right": + if (options.legendVerticalPosition === "center" || options.legendVerticalPosition === "middle") { + return width + options.legendMargin[3]; + } + return width - parent.getDim("width") - options.legendMargin[1]; + case "middle": + case "center": + return Math.round(width/2 - parent.getDim("width")/2); + default: + return options.legendMargin[3]; } } function getLegendYPosition() { - switch(calendar.options.legendVerticalPosition) { - case "center": - case "middle": - case "top": return calendar.options.legendMargin[0]; - case "bottom": return calendar.graphDim.height + calendar.options.legendMargin[0]; + switch(options.legendVerticalPosition) { + case "center": + case "middle": + case "top": + return options.legendMargin[0]; + case "bottom": + return calendar.graphDim.height + options.legendMargin[0] - options.domainGutter - options.cellPadding; } } @@ -2759,30 +3092,38 @@ Legend.prototype.redraw = function(width) { * @return int height or width in pixels */ Legend.prototype.getDim = function(axis) { + "use strict"; + switch(axis) { - case "width": return this.dim[this.calendar.options.legendOrientation === "horizontal" ? "width": "height"]; - case "height": return this.dim[this.calendar.options.legendOrientation === "horizontal" ? "height": "width"]; + case "width": + return this.dim[this.calendar.options.legendOrientation === "horizontal" ? "width": "height"]; + case "height": + return this.dim[this.calendar.options.legendOrientation === "horizontal" ? "height": "width"]; } }; Legend.prototype.buildColors = function() { - if (this.calendar.options.legendColors === null) { + "use strict"; + + var options = this.calendar.options; // Shorter accessor for variable name mangling when minifying + + if (options.legendColors === null) { this.calendar.legendScale = null; return false; } var _colorRange = []; - if (Array.isArray(this.calendar.options.legendColors)) { - _colorRange = this.calendar.options.legendColors; - } else if (this.calendar.options.legendColors.hasOwnProperty("min") && this.calendar.options.legendColors.hasOwnProperty("max")) { - _colorRange = [this.calendar.options.legendColors.min, this.calendar.options.legendColors.max]; + if (Array.isArray(options.legendColors)) { + _colorRange = options.legendColors; + } else if (options.legendColors.hasOwnProperty("min") && options.legendColors.hasOwnProperty("max")) { + _colorRange = [options.legendColors.min, options.legendColors.max]; } else { - this.calendar.options.legendColors = null; + options.legendColors = null; return false; } - var _legend = this.calendar.options.legend.slice(0); + var _legend = options.legend.slice(0); if (_legend[0] > 0) { _legend.unshift(0); @@ -2798,7 +3139,7 @@ Legend.prototype.buildColors = function() { ; var legendColors = _legend.map(function(element) { return colorScale(element); }); - this.calendar.legendScale = d3.scale.threshold().domain(this.calendar.options.legend).range(legendColors); + this.calendar.legendScale = d3.scale.threshold().domain(options.legend).range(legendColors); return true; }; @@ -2813,6 +3154,7 @@ Legend.prototype.buildColors = function() { * @return string Classname according to the legend */ Legend.prototype.getClass = function(n, withCssClass) { + "use strict"; if (n === null || isNaN(n)) { return ""; @@ -2847,10 +3189,14 @@ Legend.prototype.getClass = function(n, withCssClass) { * @return String */ String.prototype.format = function () { + "use strict"; + var formatted = this; for (var prop in arguments[0]) { - var regexp = new RegExp("\\{" + prop + "\\}", "gi"); - formatted = formatted.replace(regexp, arguments[0][prop]); + if (arguments[0].hasOwnProperty(prop)) { + var regexp = new RegExp("\\{" + prop + "\\}", "gi"); + formatted = formatted.replace(regexp, arguments[0][prop]); + } } return formatted; }; @@ -2859,7 +3205,9 @@ String.prototype.format = function () { * #source http://stackoverflow.com/a/383245/805649 */ function mergeRecursive(obj1, obj2) { + "use strict"; + /*jshint forin:false */ for (var p in obj2) { try { // Property in destination object set; update its value. @@ -2884,26 +3232,28 @@ function mergeRecursive(obj1, obj2) { * @param array array the array to compare to * @return bool true of the 2 arrays are equals */ -function arrayEquals(array_a, array_b) { +function arrayEquals(arrayA, arrayB) { + "use strict"; + // if the other array is a falsy value, return - if (!array_b || !array_a) { + if (!arrayB || !arrayA) { return false; } // compare lengths - can save a lot of time - if (array_a.length !== array_b.length) { + if (arrayA.length !== arrayB.length) { return false; } - for (var i = 0; i < array_a.length; i++) { + for (var i = 0; i < arrayA.length; i++) { // Check if we have nested arrays - if (array_a[i] instanceof Array && array_b[i] instanceof Array) { + if (arrayA[i] instanceof Array && arrayB[i] instanceof Array) { // recurse into the nested arrays - if (!arrayEquals(array_a[i], array_b[i])) { + if (!arrayEquals(arrayA[i], arrayB[i])) { return false; } } - else if (array_a[i] !== array_b[i]) { + else if (arrayA[i] !== arrayB[i]) { // Warning - two different object instances will never be equal: {x:20} != {x:20} return false; } @@ -2916,6 +3266,8 @@ function arrayEquals(array_a, array_b) { */ if (typeof define === "function" && define.amd) { define(["d3"], function() { + "use strict"; + return CalHeatMap; }); } diff --git a/cal-heatmap.min.js b/cal-heatmap.min.js index 55ea42db..c6c300e3 100644 --- a/cal-heatmap.min.js +++ b/cal-heatmap.min.js @@ -1,10 +1,10 @@ -/*! cal-heatmap v3.3.3 (Wed Oct 09 2013 18:18:05) +/*! cal-heatmap v3.3.5 (Wed Oct 16 2013 23:56:36) * --------------------------------------------- - * Cal-Heatmap is a javascript module to create calendar heatmap to visualize time series data, a la github contribution graph + * Cal-Heatmap is a javascript module to create calendar heatmap to visualize time series data * https://github.com/kamisama/cal-heatmap * Licensed under the MIT license * Copyright 2013 Wan Qi Chen */ -function mergeRecursive(t,e){for(var n in e)try{t[n]=e[n].constructor===Object?mergeRecursive(t[n],e[n]):e[n]}catch(o){t[n]=e[n]}return t}function arrayEquals(t,e){if(!e||!t)return!1;if(t.length!==e.length)return!1;for(var n=0;t.length>n;n++)if(t[n]instanceof Array&&e[n]instanceof Array){if(!arrayEquals(t[n],e[n]))return!1}else if(t[n]!==e[n])return!1;return!0}var CalHeatMap=function(){"use strict";function t(){if(o.getDomain(o.options.start).map(function(t){return t.getTime()}).map(function(t){o._domains.set(t,o.getSubDomain(t).map(function(t){return{t:o._domainType[o.options.subDomain].extractUnit(t),v:null}}))}),o.root=d3.select(o.options.itemSelector).append("svg").attr("class","cal-heatmap-container"),o.tooltip=d3.select(o.options.itemSelector).attr("style","position:relative;").append("div").attr("class","ch-tooltip"),o.root.attr("x",0).attr("y",0).append("svg").attr("class","graph"),o.Legend=new Legend(o),o.options.paintOnLoad)if(o.verticalDomainLabel="top"===o.options.label.position||"bottom"===o.options.label.position,o.domainVerticalLabelHeight=null===o.options.label.height?Math.max(25,2*o.options.cellSize):o.options.label.height,o.domainHorizontalLabelWidth=0,""===o.options.domainLabelFormat&&null===o.options.label.height&&(o.domainVerticalLabelHeight=0),o.verticalDomainLabel||(o.domainVerticalLabelHeight=0,o.domainHorizontalLabelWidth=o.options.label.width),"number"==typeof o.options.domainMargin&&(o.options.domainMargin=[o.options.domainMargin,o.options.domainMargin,o.options.domainMargin,o.options.domainMargin]),o.paint(),o.options.nextSelector!==!1&&d3.select(o.options.nextSelector).on("click."+o.options.itemNamespace,function(){return d3.event.preventDefault(),o.loadNextDomain()}),o.options.previousSelector!==!1&&d3.select(o.options.previousSelector).on("click."+o.options.itemNamespace,function(){return d3.event.preventDefault(),o.loadPreviousDomain()}),o.options.displayLegend&&o.Legend.redraw(o.graphDim.width-o.options.domainGutter-o.options.cellPadding),null!==o.options.afterLoad&&o.afterLoad(),o.options.loadOnInit){var t=o.getDomainKeys();o.getDatas(o.options.data,new Date(t[0]),o.getSubDomain(t[t.length-1]).pop(),function(){o.fill(),o.onComplete()})}else o.onComplete();return!0}function e(t,e){var n=o.options.cellSize*o._domainType[o.options.subDomain].column(t)+o.options.cellPadding*o._domainType[o.options.subDomain].column(t);return e!==void 0&&e===!0?n+=o.domainHorizontalLabelWidth+o.options.domainGutter+o.options.domainMargin[1]+o.options.domainMargin[3]:n}function n(t,e){var n=o.options.cellSize*o._domainType[o.options.subDomain].row(t)+o.options.cellPadding*o._domainType[o.options.subDomain].row(t);return e!==void 0&&e===!0&&(n+=o.options.domainGutter+o.domainVerticalLabelHeight+o.options.domainMargin[0]+o.options.domainMargin[2]),n}var o=this,i=["json","csv","tsv","txt"];this.options={itemSelector:"#cal-heatmap",paintOnLoad:!0,range:12,cellSize:10,cellPadding:2,cellRadius:0,domainGutter:2,domainMargin:[0,0,0,0],domain:"hour",subDomain:"min",colLimit:null,rowLimit:null,weekStartOnMonday:!0,start:new Date,minDate:null,maxDate:null,data:"",dataType:i[0],considerMissingDataAsZero:!1,loadOnInit:!0,verticalOrientation:!1,domainDynamicDimension:!0,label:{position:"bottom",align:"center",offset:{x:0,y:0},rotate:null,width:100,height:null},legend:[10,20,30,40],displayLegend:!0,legendCellSize:10,legendCellPadding:2,legendMargin:[0,0,0,0],legendVerticalPosition:"bottom",legendHorizontalPosition:"left",legendOrientation:"horizontal",legendColors:null,highlight:[],itemName:["item","items"],domainLabelFormat:null,subDomainTitleFormat:{empty:"{date}",filled:"{count} {name} {connector} {date}"},subDomainDateFormat:null,subDomainTextFormat:null,legendTitleFormat:{lower:"less than {min} {name}",inner:"between {down} and {up} {name}",upper:"more than {max} {name}"},animationDuration:500,nextSelector:!1,previousSelector:!1,itemNamespace:"cal-heatmap",tooltip:!1,onClick:null,afterLoad:null,afterLoadNextDomain:null,afterLoadPreviousDomain:null,onComplete:null,afterLoadData:function(t){return t},onMaxDomainReached:null,onMinDomainReached:null},this._domainType={min:{name:"minute",level:10,row:function(){return o.options.colLimit>0?Math.ceil(60/o.options.colLimit):o.options.rowLimit||10},column:function(){return o.options.rowLimit>0?Math.ceil(60/o.options.rowLimit):o.options.colLimit||6},position:{x:function(t){return Math.floor(t.getMinutes()/o._domainType.min.row(t))},y:function(t){return t.getMinutes()%o._domainType.min.row(t)}},format:{date:"%H:%M, %A %B %-e, %Y",legend:"",connector:"at"},extractUnit:function(t){var e=new Date(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes());return e.getTime()}},hour:{name:"hour",level:20,row:function(t){if(o.options.colLimit>0){var e=24;return"week"===o.options.domain?e=168:"month"===o.options.domain&&(e=24*o.getDayCountInMonth(t)),Math.ceil(e/o.options.colLimit)}return o.options.rowLimit||6},column:function(t){if(o.options.colLimit>0)return o.options.colLimit;switch(o.options.domain){case"day":return o.options.rowLimit>0?Math.ceil(24/o.options.rowLimit):4;case"week":return o.options.rowLimit>0?Math.ceil(168/o.options.rowLimit):28;case"month":return o.options.rowLimit>0?Math.ceil(744/o.options.rowLimit):4*(o.options.domainDynamicDimension?o.getEndOfMonth(t).getDate():31)}},position:{x:function(t){return"month"===o.options.domain?o.options.colLimit>0||o.options.rowLimit>0?Math.floor((t.getHours()+24*(t.getDate()-1))/o._domainType.hour.row(t)):Math.floor(t.getHours()/o._domainType.hour.row(t))+4*(t.getDate()-1):"week"===o.options.domain?o.options.colLimit>0||o.options.rowLimit>0?Math.floor((t.getHours()+24*o.getWeekDay(t))/o._domainType.hour.row(t)):Math.floor(t.getHours()/o._domainType.hour.row(t))+4*o.getWeekDay(t):Math.floor(t.getHours()/o._domainType.hour.row(t))},y:function(t){if(o.options.colLimit>0||o.options.rowLimit>0)switch(o.options.domain){case"month":return Math.floor((t.getHours()+24*(t.getDate()-1))%o._domainType.hour.row(t));case"week":return Math.floor((t.getHours()+24*o.getWeekDay(t))%o._domainType.hour.row(t))}return t.getHours()%o._domainType.hour.row(t)}},format:{date:"%Hh, %A %B %-e, %Y",legend:"%H:00",connector:"at"},extractUnit:function(t){var e=new Date(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours());return e.getTime()}},day:{name:"day",level:30,row:function(t){if(o.options.colLimit>0){var e=0;switch(o.options.domain){case"year":e=o.getDayCountInYear(t);break;case"month":e=o.getDayCountInMonth(t);break;case"week":e=7}return Math.ceil(e/o.options.colLimit)}return o.options.rowLimit||7},column:function(t){if(o.options.colLimit>0)return o.options.colLimit;switch(t=new Date(t),o.options.domain){case"year":if(o.options.rowLimit>0){var e=o.options.domainDynamicDimension?o.getDayCountInYear(t):366;return Math.ceil(e/o.options.rowLimit)}return o.options.domainDynamicDimension?o.getWeekNumber(new Date(t.getFullYear(),11,31))-o.getWeekNumber(new Date(t.getFullYear(),0))+1:54;case"month":if(o.options.rowLimit>0){var n=o.options.domainDynamicDimension?new Date(t.getFullYear(),t.getMonth()+1,0).getDate():31;return Math.ceil(n/o.options.rowLimit)}return o.options.verticalOrientation?6:o.options.domainDynamicDimension?o.getWeekNumber(new Date(t.getFullYear(),t.getMonth()+1,0))-o.getWeekNumber(t)+1:6;case"week":return Math.ceil(7/o._domainType.day.row(t))}},position:{x:function(t){switch(o.options.domain){case"week":return Math.floor(o.getWeekDay(t)/o._domainType.day.row(t));case"month":return o.options.colLimit>0||o.options.rowLimit>0?Math.floor((t.getDate()-1)/o._domainType.day.row(t)):o.getWeekNumber(t)-o.getWeekNumber(new Date(t.getFullYear(),t.getMonth()));case"year":return o.options.colLimit>0||o.options.rowLimit>0?Math.floor((o.getDayOfYear(t)-1)/o._domainType.day.row(t)):o.getWeekNumber(t)}},y:function(t){if(o.options.colLimit>0||o.options.rowLimit>0)switch(o.options.domain){case"year":return Math.floor((o.getDayOfYear(t)-1)%o._domainType.day.row(t));case"week":return Math.floor(o.getWeekDay(t)%o._domainType.day.row(t));case"month":return Math.floor((t.getDate()-1)%o._domainType.day.row(t))}return o.getWeekDay(t)%o._domainType.day.row(t)}},format:{date:"%A %B %-e, %Y",legend:"%e %b",connector:"on"},extractUnit:function(t){var e=new Date(t.getFullYear(),t.getMonth(),t.getDate());return e.getTime()}},week:{name:"week",level:40,row:function(){return o.options.colLimit>0?Math.ceil(54/o.options.colLimit):o.options.rowLimit||1},column:function(t){if(o.options.colLimit>0)return o.options.colLimit;switch(t=new Date(t),o.options.domain){case"year":return 54;case"month":return o.getWeekNumber(new Date(t.getFullYear(),t.getMonth()+1,0))-o.getWeekNumber(t);default:return 1}},position:{x:function(t){switch(o.options.domain){case"year":return o.options.colLimit>0||o.options.rowLimit>0?Math.floor(o.getWeekNumber(t)/o._domainType.week.row(t)):o.getWeekNumber(t);case"month":var e=o.getMonthWeekNumber(t);return o.options.colLimit>0||o.options.rowLimit>0?Math.floor((e-1)/o._domainType.week.row(t)):e}},y:function(t){return o.getWeekNumber(t)%o._domainType.week.row(t)}},format:{date:"%B Week #%W",legend:"%B Week #%W",connector:"on"},extractUnit:function(t){var e=new Date(t.getFullYear(),t.getMonth(),t.getDate()),n=e.getDay()-1;return 0>n&&(n=6),e.setDate(e.getDate()-n),e.getTime()}},month:{name:"month",level:50,row:function(){return o.options.colLimit>0?Math.ceil(12/o.options.colLimit):o.options.rowLimit||1},column:function(){return o.options.rowLimit>0?Math.ceil(12/o.options.rowLimit):o.options.colLimit||12},position:{x:function(t){return Math.floor(t.getMonth()/o._domainType.month.row(t))},y:function(t){return t.getMonth()%o._domainType.month.row(t)}},format:{date:"%B %Y",legend:"%B",connector:"on"},extractUnit:function(t){var e=new Date(t.getFullYear(),t.getMonth());return e.getTime()}},year:{name:"year",level:60,row:function(){return o.options.rowLimit||1},column:function(){return o.options.colLimit||1},position:{x:function(){return 1},y:function(){return 1}},format:{date:"%Y",legend:"%Y",connector:"on"},extractUnit:function(t){var e=new Date(t.getFullYear());return e.getTime()}}};for(var a in this._domainType)this._domainType["x_"+a]={},this._domainType["x_"+a].name="x_"+a,this._domainType["x_"+a].level=this._domainType[a].level,this._domainType["x_"+a].row=this._domainType[a].column,this._domainType["x_"+a].column=this._domainType[a].row,this._domainType["x_"+a].position={},this._domainType["x_"+a].position.x=this._domainType[a].position.y,this._domainType["x_"+a].position.y=this._domainType[a].position.x,this._domainType["x_"+a].format=this._domainType[a].format,this._domainType["x_"+a].extractUnit=this._domainType[a].extractUnit;this._domainType.x_day.row=function(t){switch(t=new Date(t),o.options.domain){case"year":return o.options.domainDynamicDimension?o.getWeekNumber(new Date(t.getFullYear(),11,31))-o.getWeekNumber(new Date(t.getFullYear(),0))+1:54;case"month":return o.options.verticalOrientation?o.options.domainDynamicDimension?o.getWeekNumber(new Date(t.getFullYear(),t.getMonth()+1,0))-o.getWeekNumber(t)+1:6:6;case"week":return 1}},this.lastInsertedSvg=null,this._completed=!1,this._domains=d3.map(),this.graphDim={width:0,height:0},this.legendDim={width:0,height:0},this.NAVIGATE_LEFT=1,this.NAVIGATE_RIGHT=2,this.RESET_ALL_ON_UPDATE=0,this.RESET_SINGLE_ON_UPDATE=1,this.APPEND_ON_UPDATE=2,this.DEFAULT_LEGEND_MARGIN=10,this.root=null,this.tooltip=null,this._maxDomainReached=!1,this._minDomainReached=!1,this.domainPosition=new DomainPosition,this.Legend=null,this.legendScale=null,this.paint=function(t){function i(e,n,i,a){var r=0;switch(t){case!1:return r=n[i],n[i]+=a,o.domainPosition.setPosition(e,r),r;case o.NAVIGATE_RIGHT:return o.domainPosition.setPosition(e,n[i]),s=a,l=o.domainPosition.getPositionFromIndex(1),o.domainPosition.shiftRightBy(l),n[i];case o.NAVIGATE_LEFT:return r=-a,s=-r,l=n[i]-o.domainPosition.getLast(),o.domainPosition.setPosition(e,r),o.domainPosition.shiftLeftBy(s),r}}function a(t){switch(o.options.label.rotate){case"right":t.attr("transform",function(t){var n="rotate(90), ";switch(o.options.label.position){case"right":n+="translate(-"+e(t)+" , -"+e(t)+")";break;case"left":n+="translate(0, -"+o.domainHorizontalLabelWidth+")"}return n});break;case"left":t.attr("transform",function(t){var n="rotate(270), ";switch(o.options.label.position){case"right":n+="translate(-"+(e(t)+o.domainHorizontalLabelWidth)+" , "+e(t)+")";break;case"left":n+="translate(-"+o.domainHorizontalLabelWidth+" , "+o.domainHorizontalLabelWidth+")"}return n})}}t===void 0&&(t=!1);var r=o.root.select(".graph").selectAll(".graph-domain").data(function(){var e=o.getDomainKeys();return t===o.NAVIGATE_LEFT?e.reverse():e},function(t){return t}),s=0,l=0,m=r.enter().append("svg").attr("width",function(t){return e(t,!0)}).attr("height",function(t){return n(t,!0)}).attr("x",function(t){return o.options.verticalOrientation?(o.graphDim.width=e(t,!0),0):i(t,o.graphDim,"width",e(t,!0))}).attr("y",function(t){return o.options.verticalOrientation?i(t,o.graphDim,"height",n(t,!0)):(o.graphDim.height=n(t,!0),0)}).attr("class",function(t){var e="graph-domain",n=new Date(t);switch(o.options.domain){case"hour":e+=" h_"+n.getHours();case"day":e+=" d_"+n.getDate()+" dy_"+n.getDay();case"week":e+=" w_"+o.getWeekNumber(n);case"month":e+=" m_"+(n.getMonth()+1);case"year":e+=" y_"+n.getFullYear()}return e});o.lastInsertedSvg=m,m.append("rect").attr("width",function(t){return e(t,!0)-o.options.domainGutter-o.options.cellPadding}).attr("height",function(t){return n(t,!0)-o.options.domainGutter-o.options.cellPadding}).attr("class","domain-background");var u=m.append("svg").attr("x",function(){return"left"===o.options.label.position?o.domainHorizontalLabelWidth+o.options.domainMargin[3]:o.options.domainMargin[3]}).attr("y",function(){return"top"===o.options.label.position?o.domainVerticalLabelHeight+o.options.domainMargin[0]:o.options.domainMargin[0]}).attr("class","graph-subdomain-group"),g=u.selectAll("g").data(function(t){return o._domains.get(t)}).enter().append("g");g.append("rect").attr("class",function(t){return"graph-rect"+o.getHighlightClassName(t.t)+(null!==o.options.onClick?" hover_cursor":"")}).attr("width",o.options.cellSize).attr("height",o.options.cellSize).attr("x",function(t){return o.positionSubDomainX(t.t)}).attr("y",function(t){return o.positionSubDomainY(t.t)}).on("click",function(t){return null!==o.options.onClick?o.onClick(new Date(t.t),t.v):void 0}).call(function(t){o.options.cellRadius>0&&t.attr("rx",o.options.cellRadius).attr("ry",o.options.cellRadius),null!==o.legendScale&&null!==o.options.legendColors&&o.options.legendColors.hasOwnProperty("base")&&t.attr("fill",o.options.legendColors.base),o.options.tooltip&&(t.on("mouseover",function(t){var e=this.parentNode.parentNode.parentNode;o.tooltip.html(o.getSubDomainTitle(t)).attr("style","display: block;"),o.tooltip.attr("style","display: block; left: "+(o.positionSubDomainX(t.t)-o.tooltip[0][0].offsetWidth/2+o.options.cellSize/2+parseInt(e.getAttribute("x"),10))+"px; "+"top: "+(o.positionSubDomainY(t.t)-o.tooltip[0][0].offsetHeight-o.options.cellSize/2+parseInt(e.getAttribute("y"),10))+"px;")}),t.on("mouseout",function(){o.tooltip.attr("style","display:none").html("")}))}),o.options.tooltip||g.append("title").text(function(t){return o.formatDate(new Date(t.t),o.options.subDomainDateFormat)}),""!==o.options.domainLabelFormat&&m.append("text").attr("class","graph-label").attr("y",function(t){var e=o.options.domainMargin[0];switch(o.options.label.position){case"top":e+=o.domainVerticalLabelHeight/2;break;case"bottom":e+=n(t)+o.domainVerticalLabelHeight/2}return e+o.options.label.offset.y*("right"===o.options.label.rotate&&"right"===o.options.label.position||"left"===o.options.label.rotate&&"left"===o.options.label.position?-1:1)}).attr("x",function(t){var n=o.options.domainMargin[3];switch(o.options.label.position){case"right":n+=e(t);break;case"bottom":case"top":n+=e(t)/2}return"right"===o.options.label.align?n+o.domainHorizontalLabelWidth-o.options.label.offset.x*("right"===o.options.label.rotate?-1:1):n+o.options.label.offset.x}).attr("text-anchor",function(){switch(o.options.label.align){case"start":case"left":return"start";case"end":case"right":return"end";default:return"middle"}}).attr("dominant-baseline",function(){return o.verticalDomainLabel?"middle":"top"}).text(function(t){return o.formatDate(new Date(t),o.options.domainLabelFormat)}).call(a),null!==o.options.subDomainTextFormat&&g.append("text").attr("class",function(t){return"subdomain-text"+o.getHighlightClassName(t.t)}).attr("x",function(t){return o.positionSubDomainX(t.t)+o.options.cellSize/2}).attr("y",function(t){return o.positionSubDomainY(t.t)+o.options.cellSize/2}).attr("text-anchor","middle").attr("dominant-baseline","central").text(function(t){return o.formatDate(new Date(t.t),o.options.subDomainTextFormat)}),t!==!1&&r.transition().duration(o.options.animationDuration).attr("x",function(t){return o.options.verticalOrientation?0:o.domainPosition.getPosition(t)}).attr("y",function(t){return o.options.verticalOrientation?o.domainPosition.getPosition(t):0});var p=o.graphDim.width,h=o.graphDim.height;o.options.verticalOrientation?o.graphDim.height+=s-l:o.graphDim.width+=s-l,r.exit().transition().duration(o.options.animationDuration).attr("x",function(n){if(o.options.verticalOrientation)return 0;switch(t){case o.NAVIGATE_LEFT:return Math.min(o.graphDim.width,p);case o.NAVIGATE_RIGHT:return-e(n,!0)}}).attr("y",function(e){if(!o.options.verticalOrientation)return 0;switch(t){case o.NAVIGATE_LEFT:return Math.min(o.graphDim.height,h);case o.NAVIGATE_RIGHT:return-n(e,!0)}}).remove(),o.resize()},this.fill=function(t){function e(t){return null===o.legendScale?!1:(t.attr("fill",function(t){return 0===t.v&&null!==o.options.legendColors&&o.options.legendColors.hasOwnProperty("empty")?o.options.legendColors.empty:0>t.v&&o.options.legend[0]>0&&null!==o.options.legendColors&&o.options.legendColors.hasOwnProperty("overflow")?o.options.legendColors.overflow:o.legendScale(Math.min(t.v,o.options.legend[o.options.legend.length-2]))}),void 0)}0===arguments.length&&(t=o.root.selectAll(".graph-domain"));var n=t.selectAll("svg").selectAll("g").data(function(t){return o._domains.get(t)});n.transition().duration(o.options.animationDuration).select("rect").attr("class",function(t){var e=o.getHighlightClassName(t.t);return null===o.legendScale&&(e+=" graph-rect"),null!==t.v?e+=" "+o.Legend.getClass(t.v,null===o.legendScale):o.options.considerMissingDataAsZero&&(e+=" "+o.Legend.getClass(0,null===o.legendScale)),null!==o.options.onClick&&(e+=" hover_cursor"),e}).call(e),n.transition().duration(o.options.animationDuration).select("title").text(function(t){return o.getSubDomainTitle(t)})},this.init=function(e){function n(t){return!(t instanceof Element)&&"string"!=typeof t||""===t}if(o.options=mergeRecursive(o.options,e),!this._domainType.hasOwnProperty(o.options.domain)||"min"===o.options.domain||"x_"===o.options.domain.substring(0,2))return console.log("The domain '"+o.options.domain+"' is not valid"),!1;if(!this._domainType.hasOwnProperty(o.options.subDomain)||"year"===o.options.subDomain)return console.log("The subDomain '"+o.options.subDomain+"' is not valid"),!1;if(this._domainType[o.options.domain].level<=this._domainType[o.options.subDomain].level)return console.log("'"+o.options.subDomain+"' is not a valid subDomain to '"+o.options.domain+"'"),!1;if(!e.hasOwnProperty("subDomain"))switch(o.options.domain){case"year":o.options.subDomain="month";break;case"month":o.options.subDomain="day";break;case"week":o.options.subDomain="day";break;case"day":o.options.subDomain="hour";break;default:o.options.subDomain="min"}if(0>i.indexOf(o.options.dataType))return console.log("The data type '"+o.options.dataType+"' is not valid data type"),!1;if(null===o.options.subDomainDateFormat&&(o.options.subDomainDateFormat=this._domainType[o.options.subDomain].format.date),null===o.options.domainLabelFormat&&(o.options.domainLabelFormat=this._domainType[o.options.domain].format.legend),!e.hasOwnProperty("label")||e.hasOwnProperty("label")&&!e.label.hasOwnProperty("align")){switch(o.options.label.position){case"left":o.options.label.align="right";break;case"right":o.options.label.align="left";break;default:o.options.label.align="center"}"left"===o.options.label.rotate?o.options.label.align="right":"right"===o.options.label.rotate&&(o.options.label.align="left")}if((!e.hasOwnProperty("label")||e.hasOwnProperty("label")&&!e.label.hasOwnProperty("offset"))&&("left"===o.options.label.position||"right"===o.options.label.position)&&(o.options.label.offset={x:10,y:15}),n(o.options.itemSelector))return console.log("The itemSelector is invalid"),!1;if(null===d3.select(o.options.itemSelector)[0][0])return console.log("The node specified in itemSelector does not exists"),!1;if(o.options.nextSelector!==!1&&n(o.options.nextSelector))return console.log("The nextSelector is invalid"),!1;if(o.options.previousSelector!==!1&&n(o.options.previousSelector))return console.log("The previousSelector is invalid"),!1;if(("string"!=typeof o.options.itemNamespace||""===o.options.itemNamespace)&&(console.log("itemNamespace can not be empty, falling back to cal-heatmap"),o.options.itemNamespace="cal-heatmap"),"number"==typeof o.options.domainMargin&&(o.options.domainMargin=[o.options.domainMargin,o.options.domainMargin,o.options.domainMargin,o.options.domainMargin]),e.hasOwnProperty("rowLimit")&&e.hasOwnProperty("colLimit")&&e.rowLimit>0&&e.colLimit>0&&(console.log("colLimit and rowLimit are mutually exclusive, rowLimit will be ignored"),o.options.rowLimit=null),Array.isArray(o.options.domainMargin))switch(o.options.domainMargin.length){case 0:o.options.domainMargin=[0,0,0,0];break;case 1:o.options.domainMargin=[o.options.domainMargin,o.options.domainMargin,o.options.domainMargin,o.options.domainMargin];break;case 2:o.options.domainMargin=[o.options.domainMargin[0],o.options.domainMargin[1],o.options.domainMargin[0],o.options.domainMargin[1]];break;case 3:o.options.domainMargin=[o.options.domainMargin[0],o.options.domainMargin[1],o.options.domainMargin[2],o.options.domainMargin[1]];break;case 4:o.options.domainMargin=o.options.domainMargin;break;default:o.options.domainMargin.splice(4)}"string"==typeof o.options.itemName?o.options.itemName=[o.options.itemName,o.options.itemName+"s"]:Array.isArray(o.options.itemName)&&1===o.options.itemName.length&&(o.options.itemName=[o.options.itemName[0],o.options.itemName[0]+"s"]);var a=["data","onComplete","onClick","afterLoad","afterLoadData","afterLoadPreviousDomain","afterLoadNextDomain"];for(var r in a)e.hasOwnProperty(a[r])&&(o.options[a[r]]=e[a[r]]);if("string"==typeof o.options.highlight)o.options.highlight="now"===o.options.highlight?[new Date]:[];else if(Array.isArray(o.options.highlight)){var s=o.options.highlight.indexOf("now");-1!==s&&(o.options.highlight.splice(s,1),o.options.highlight.push(new Date))}return e.hasOwnProperty("legendMargin")||("top"===o.options.legendVerticalPosition?o.options.legendMargin[0]=o.DEFAULT_LEGEND_MARGIN:"bottom"===o.options.legendVerticalPosition&&(o.options.legendMargin[2]=o.DEFAULT_LEGEND_MARGIN),("middle"===o.options.legendHorizontalPosition||"center"===o.options.legendHorizontalPosition)&&("left"===o.options.legendVerticalPosition?o.options.legendMargin[1]=o.DEFAULT_LEGEND_MARGIN:"right"===o.options.legendVerticalPosition&&(o.options.legendMargin[3]=o.DEFAULT_LEGEND_MARGIN))),t()}};CalHeatMap.prototype={triggerEvent:function(t,e,n){return 3===arguments.length&&n||null===this.options[t]?!0:"function"==typeof this.options[t]?("function"==typeof e&&(e=e()),this.options[t].apply(this,e)):(console.log("Provided callback for "+t+" is not a function."),!1)},onClick:function(t,e){return this.triggerEvent("onClick",[t,e])},afterLoad:function(){return this.triggerEvent("afterLoad")},onComplete:function(){var t=this.triggerEvent("onComplete",[],this._completed);return this._completed=!0,t},afterLoadPreviousDomain:function(t){var e=this;return this.triggerEvent("afterLoadPreviousDomain",function(){var n=e.getSubDomain(t);return[n.shift(),n.pop()]})},afterLoadNextDomain:function(t){var e=this;return this.triggerEvent("afterLoadNextDomain",function(){var n=e.getSubDomain(t);return[n.shift(),n.pop()]})},onMinDomainReached:function(t){return this._minDomainReached=t,this.triggerEvent("onMinDomainReached",[t])},onMaxDomainReached:function(t){return this._maxDomainReached=t,this.triggerEvent("onMaxDomainReached",[t])},formatNumber:d3.format(",g"),formatDate:function(t,e){if(e===void 0&&(e="title"),"function"==typeof e)return e(t);var n=d3.time.format(e);return n(t)},getSubDomainTitle:function(t){if(null!==t.v||this.options.considerMissingDataAsZero){var e=t.v;return null===e&&this.options.considerMissingDataAsZero&&(e=0),this.options.subDomainTitleFormat.filled.format({count:this.formatNumber(e),name:this.options.itemName[1!==e?1:0],connector:this._domainType[this.options.subDomain].format.connector,date:this.formatDate(new Date(t.t),this.options.subDomainDateFormat)})}return this.options.subDomainTitleFormat.empty.format({date:this.formatDate(new Date(t.t),this.options.subDomainDateFormat)})},loadNextDomain:function(t){if(this._maxDomainReached||0===t)return!1;0===arguments.length&&(t=1);for(var e=this.getDomain(this.getNextDomain(),t),n=this,o=-1,i=e.length;i>++o;){if(this.maxDomainIsReached(e[o])){e=e.slice(0,o);break}this._domains.set(e[o].getTime(),this.getSubDomain(e[o]).map(function(t){return{t:n._domainType[n.options.subDomain].extractUnit(t),v:null}}))}var a=this.getDomainKeys();return a.slice(0,e.length).forEach(function(t){n._domains.remove(t)}),this.paint(this.NAVIGATE_RIGHT),this.getDatas(this.options.data,e[0],this.getSubDomain(e[e.length-1]).pop(),function(){n.fill(n.lastInsertedSvg)}),this.afterLoadNextDomain(e[e.length-1]),this.maxDomainIsReached(this.getNextDomain().getTime())&&this.onMaxDomainReached(!0),this._minDomainReached&&!this.minDomainIsReached(a[1])&&this.onMinDomainReached(!1),!0},loadPreviousDomain:function(t){if(this._minDomainReached||0===t)return!1;0===arguments.length&&(t=1);for(var e=this.getDomainKeys(),n=this.getDomain(e[0],-t).reverse(),o=this,i=-1,a=n.length;a>++i;)if(this.minDomainIsReached(n[i])){n=n.slice(0,i+1);break}for(i=0,a=n.length;a>i;i++)o._domains.set(n[i].getTime(),o.getSubDomain(n[i]).map(function(t){return{t:o._domainType[o.options.subDomain].extractUnit(t),v:null}}));return e=this.getDomainKeys(),e.slice(-n.length).forEach(function(t){o._domains.remove(t)}),n=n.reverse(),this.paint(this.NAVIGATE_LEFT),this.getDatas(this.options.data,n[0],this.getSubDomain(n[n.length-1]).pop(),function(){o.fill(o.lastInsertedSvg)}),this.afterLoadPreviousDomain(n[0]),this.minDomainIsReached(n[0])&&this.onMinDomainReached(!0),this._maxDomainReached&&!this.maxDomainIsReached(e[e.length-1])&&this.onMaxDomainReached(!1),!0},maxDomainIsReached:function(t){return null!==this.options.maxDate&&t>this.options.maxDate.getTime()},minDomainIsReached:function(t){return null!==this.options.minDate&&this.options.minDate.getTime()>=t},getDomainKeys:function(){return this._domains.keys().map(function(t){return parseInt(t,10)}).sort(function(t,e){return t-e})},positionSubDomainX:function(t){var e=this._domainType[this.options.subDomain].position.x(new Date(t));return e*this.options.cellSize+e*this.options.cellPadding},positionSubDomainY:function(t){var e=this._domainType[this.options.subDomain].position.y(new Date(t));return e*this.options.cellSize+e*this.options.cellPadding},getHighlightClassName:function(t){if(t=new Date(t),this.options.highlight.length>0)for(var e in this.options.highlight)if(this.options.highlight[e]instanceof Date&&this.dateIsEqual(this.options.highlight[e],t))return" highlight"+(this.isNow(this.options.highlight[e])?" now":"");return""},isNow:function(t){return this.dateIsEqual(t,new Date)},dateIsEqual:function(t,e){switch(this.options.subDomain){case"x_min":case"min":return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()&&t.getHours()===e.getHours()&&t.getMinutes()===e.getMinutes();case"x_hour":case"hour":return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()&&t.getHours()===e.getHours();case"x_day":case"day":return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate();case"x_week":case"week":case"x_month":case"month":return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth();default:return!1}},getDayOfYear:d3.time.format("%j"),getWeekNumber:function(t){var e=this.options.weekStartOnMonday===!0?d3.time.format("%W"):d3.time.format("%U");return e(t)},getMonthWeekNumber:function(t){"number"==typeof t&&(t=new Date(t));var e=this.getWeekNumber(new Date(t.getFullYear(),t.getMonth()));return this.getWeekNumber(t)-e-1},getWeekNumberInYear:function(t){"number"==typeof t&&(t=new Date(t))},getDayCountInMonth:function(t){return this.getEndOfMonth(t).getDate()},getDayCountInYear:function(t){return"number"==typeof t&&(t=new Date(t)),0===t.getFullYear()%400?366:365},getWeekDay:function(t){return this.options.weekStartOnMonday===!1?t.getDay():0===t.getDay()?6:t.getDay()-1},getEndOfMonth:function(t){return"number"==typeof t&&(t=new Date(t)),new Date(t.getFullYear(),t.getMonth()+1,0)},jumpDate:function(t,e,n){var o=new Date(t);switch(n){case"hour":o.setHours(o.getHours()+e);break;case"day":o.setHours(o.getHours()+24*e);break;case"week":o.setHours(o.getHours()+7*24*e);break;case"month":o.setMonth(o.getMonth()+e);break;case"year":o.setFullYear(o.getFullYear()+e)}return new Date(o)},getMinuteDomain:function(t,e){var n=new Date(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours()),o=null;return o="object"==typeof e?new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours()):new Date(n.getTime()+6e4*e),d3.time.minutes(Math.min(n,o),Math.max(n,o))},getHourDomain:function(t,e){var n=new Date(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours()),o=null;return o="object"==typeof e?new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours()):new Date(n.getTime()+36e5*e),d3.time.hours(Math.min(n,o),Math.max(n,o))},getDayDomain:function(t,e){var n=new Date(t.getFullYear(),t.getMonth(),t.getDate()),o=null;return"object"==typeof e?o=new Date(e.getFullYear(),e.getMonth(),e.getDate()):(o=new Date(n),o=new Date(o.setDate(o.getDate()+parseInt(e,10)))),d3.time.days(Math.min(n,o),Math.max(n,o))},getWeekDomain:function(t,e){var n;this.options.weekStartOnMonday===!1?n=new Date(t.getFullYear(),t.getMonth(),t.getDate()-t.getDay()):1===t.getDay()?n=new Date(t.getFullYear(),t.getMonth(),t.getDate()):0===t.getDay()?(n=new Date(t.getFullYear(),t.getMonth(),t.getDate()),n.setDate(n.getDate()-6)):n=new Date(t.getFullYear(),t.getMonth(),t.getDate()-t.getDay()+1);var o=new Date(n),i=e;return"object"!=typeof e&&(i=new Date(o.setDate(o.getDate()+7*e))),this.options.weekStartOnMonday===!0?d3.time.mondays(Math.min(n,i),Math.max(n,i)):d3.time.sundays(Math.min(n,i),Math.max(n,i))},getMonthDomain:function(t,e){var n=new Date(t.getFullYear(),t.getMonth()),o=null;return"object"==typeof e?o=new Date(e.getFullYear(),e.getMonth()):(o=new Date(n),o=o.setMonth(o.getMonth()+e)),d3.time.months(Math.min(n,o),Math.max(n,o))},getYearDomain:function(t,e){var n=new Date(t.getFullYear(),0),o=null;return o="object"==typeof e?new Date(e.getFullYear(),0):new Date(t.getFullYear()+e,0),d3.time.years(Math.min(n,o),Math.max(n,o))},getDomain:function(t,e){switch("number"==typeof t&&(t=new Date(t)),2>arguments.length&&(e=this.options.range),this.options.domain){case"hour":return this.getHourDomain(t,e);case"day":return this.getDayDomain(t,e);case"week":return this.getWeekDomain(t,e);case"month":return this.getMonthDomain(t,e);case"year":return this.getYearDomain(t,e)}},getSubDomain:function(t){"number"==typeof t&&(t=new Date(t));var e=this,n=function(t,n){switch(n){case"year":return e.getDayCountInYear(t);case"month":return e.getDayCountInMonth(t); -case"week":return 7}},o=function(t,e){switch(e){case"hour":return 60;case"day":return 1440;case"week":return 10080}},i=function(t,n){switch(n){case"day":return 24;case"week":return 168;case"month":return 24*e.getDayCountInMonth(t)}},a=function(t,n){if("month"===n){var o=new Date(t.getFullYear(),t.getMonth()+1,0),i=e.getWeekNumber(o),a=e.getWeekNumber(new Date(t.getFullYear(),t.getMonth()));return a>i&&(a=0,i++),i-a+1}return"year"===n?e.getWeekNumber(new Date(t.getFullYear(),11,31)):void 0};switch(this.options.subDomain){case"x_min":case"min":return this.getMinuteDomain(t,o(t,this.options.domain));case"x_hour":case"hour":return this.getHourDomain(t,i(t,this.options.domain));case"x_day":case"day":return this.getDayDomain(t,n(t,this.options.domain));case"x_week":case"week":return this.getWeekDomain(t,a(t,this.options.domain));case"x_month":case"month":return this.getMonthDomain(t,12)}},getNextDomain:function(t){return 0===arguments.length&&(t=1),this.getDomain(this.jumpDate(this.getDomainKeys().pop(),t,this.options.domain),1)[0]},getPreviousDomain:function(t){return 0===arguments.length&&(t=1),this.getDomain(this.jumpDate(this.getDomainKeys().shift(),-t,this.options.domain),1)[0]},getDatas:function(t,e,n,o,i,a){var r=this;5>arguments.length&&(i=!0),6>arguments.length&&(a=this.APPEND_ON_UPDATE);var s=function(t){if(i!==!1)if("function"==typeof i)t=i(t);else{if("function"!=typeof r.options.afterLoadData)return console.log("Provided callback for afterLoadData is not a function."),{};t=r.options.afterLoadData(t)}r.parseDatas(t,a,e,n),o()};switch(typeof t){case"string":if(""===t)return s({}),!0;switch(this.options.dataType){case"json":d3.json(this.parseURI(t,e,n),s);break;case"csv":d3.csv(this.parseURI(t,e,n),s);break;case"tsv":d3.tsv(this.parseURI(t,e,n),s);break;case"text":d3.text(this.parseURI(t,e,n),"text/plain",s)}return!1;case"object":if(t===Object(t)&&"[object Array]"!==Object.prototype.toString.call(t))return s(t),!1}return!0},parseDatas:function(t,e,n,o){e===this.RESET_ALL_ON_UPDATE&&this._domains.forEach(function(t,e){e.forEach(function(t,e,n){n[e].v=null})});var i=this._domains.keys(),a=this._domains.get(i[0])[1].t-this._domains.get(i[0])[0].t;for(var r in t)if(!isNaN(r)){var s=new Date(1e3*r),l=this.getDomain(s)[0].getTime();if(this._domains.has(l)&&l>=+n&&+o>l){var m=this._domainType[this.options.subDomain].extractUnit(s),u=this._domains.get(l),g=Math.round((m-l)/a);e===this.RESET_SINGLE_ON_UPDATE?u[g].v=t[r]:isNaN(u[g].v)?u[g].v=t[r]:u[g].v+=t[r]}}},parseURI:function(t,e,n){return t=t.replace(/\{\{t:start\}\}/g,e.getTime()/1e3),t=t.replace(/\{\{t:end\}\}/g,n.getTime()/1e3),t=t.replace(/\{\{d:start\}\}/g,e.toISOString()),t=t.replace(/\{\{d:end\}\}/g,n.toISOString())},resize:function(){var t=this,e=t.options.displayLegend?t.Legend.getDim("width")+t.options.legendMargin[1]+t.options.legendMargin[3]:0,n=t.options.displayLegend?t.Legend.getDim("height")+t.options.legendMargin[0]+t.options.legendMargin[2]:0,o=t.graphDim.width-t.options.domainGutter-t.options.cellPadding,i=t.graphDim.height-t.options.domainGutter-t.options.cellPadding;this.root.transition().duration(t.options.animationDuration).attr("width",function(){return"middle"===t.options.legendVerticalPosition||"center"===t.options.legendVerticalPosition?o+e:Math.max(o,e)}).attr("height",function(){return"middle"===t.options.legendVerticalPosition||"center"===t.options.legendVerticalPosition?Math.max(i,n):i+n}),this.root.select(".graph").transition().duration(t.options.animationDuration).attr("y",function(){return"top"===t.options.legendVerticalPosition?n:0}).attr("x",function(){return"middle"!==t.options.legendVerticalPosition&&"center"!==t.options.legendVerticalPosition||"left"!==t.options.legendHorizontalPosition?0:e})},next:function(t){return 0===arguments.length&&(t=1),this.loadNextDomain(t)},previous:function(t){return 0===arguments.length&&(t=1),this.loadPreviousDomain(t)},jumpTo:function(t,e){2>arguments.length&&(e=!1);var n=this.getDomainKeys(),o=n[0],i=n[n.length-1];return o>t?this.loadPreviousDomain(this.getDomain(o,t).length):e?this.loadNextDomain(this.getDomain(o,t).length):t>i?this.loadNextDomain(this.getDomain(i,t).length):!1},update:function(t,e,n){2>arguments.length&&(e=!0),3>arguments.length&&(n=this.RESET_ALL_ON_UPDATE);var o=this.getDomainKeys(),i=this;this.getDatas(t,new Date(o[0]),this.getSubDomain(o[o.length-1]).pop(),function(){i.fill()},e,n)},setLegend:function(){var t=this.options.legend.slice(0);arguments.length>=1&&Array.isArray(arguments[0])&&(this.options.legend=arguments[0]),arguments.length>=2&&(this.options.legendColors=Array.isArray(arguments[1])&&arguments[1].length>=2?[arguments[1][0],arguments[1][1]]:arguments[1]),(arguments.length>0&&!arrayEquals(t,this.options.legend)||arguments.length>=2)&&(this.Legend.buildColors(),this.fill()),this.options.displayLegend&&this.Legend.redraw(this.graphDim.width-this.options.domainGutter-this.options.cellPadding)},removeLegend:function(){return this.options.displayLegend?(this.options.displayLegend=!1,this.Legend.remove(),!0):!1},showLegend:function(){return this.options.displayLegend?!1:(this.options.displayLegend=!0,this.Legend.redraw(this.graphDim.width-this.options.domainGutter-this.options.cellPadding),!0)},getSVG:function(){for(var t={".graph":{},".graph-rect":{},"rect.highlight":{},"rect.now":{},"text.highlight":{},"text.now":{},".domain-background":{},".graph-label":{},".subdomain-text":{},".qi":{}},e=0,n=this.options.legend.length;n>e;e++)t[".q"+e]={};var o=this.root,i=["stroke","stroke-width","stroke-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-miterlimit","fill","fill-opacity","fill-rule","marker","marker-start","marker-mid","marker-end","alignement-baseline","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","kerning","text-anchor","shape-rendering","text-transform","font-family","font","font-size","font-weight"],a=function(e,n,o){-1!==i.indexOf(n)&&(t[e][n]=o)},r=function(t){return o.select(t)[0][0]};for(var s in t){var l=r(s);if(null!==l)if("getComputedStyle"in window){var m=getComputedStyle(l,null);if(0!==m.length)for(var u=0;m.length>u;u++)a(s,m.item(u),m.getPropertyValue(m.item(u)));else for(var g in m)m.hasOwnProperty(g)&&a(s,g,m[g])}else if("currentStyle"in l){var p=l.currentStyle;for(var h in p)a(s,h,p[h])}}var c='",c+=(new XMLSerializer).serializeToString(this.root.selectAll("svg")[0][0]),c+=(new XMLSerializer).serializeToString(this.root.selectAll("svg")[0][1]),c+=""}};var DomainPosition=function(){this.positions=d3.map()};DomainPosition.prototype.getPosition=function(t){return this.positions.get(t)},DomainPosition.prototype.getPositionFromIndex=function(t){var e=this.getKeys();return this.positions.get(e[t])},DomainPosition.prototype.getLast=function(){var t=this.getKeys();return this.positions.get(t[t.length-1])},DomainPosition.prototype.setPosition=function(t,e){this.positions.set(t,e)},DomainPosition.prototype.shiftRightBy=function(t){this.positions.forEach(function(e,n){this.set(e,n-t)});var e=this.getKeys();this.positions.remove(e[0])},DomainPosition.prototype.shiftLeftBy=function(t){this.positions.forEach(function(e,n){this.set(e,n+t)});var e=this.getKeys();this.positions.remove(e[e.length-1])},DomainPosition.prototype.getKeys=function(){return this.positions.keys().sort(function(t,e){return parseInt(t,10)-parseInt(e,10)})};var Legend=function(t){this.calendar=t,this.computeDim(),null!==t.options.legendColors&&this.buildColors()};Legend.prototype.computeDim=function(){this.dim={width:this.calendar.options.legendCellSize*(this.calendar.options.legend.length+1)+this.calendar.options.legendCellPadding*this.calendar.options.legend.length+1,height:this.calendar.options.legendCellSize+1}},Legend.prototype.remove=function(){this.calendar.root.select(".graph-legend").remove(),this.calendar.resize()},Legend.prototype.redraw=function(t){function e(t){t.attr("width",r.options.legendCellSize).attr("height",r.options.legendCellSize).attr("x",function(t,e){return e*(r.options.legendCellSize+r.options.legendCellPadding)})}function n(){switch(r.options.legendHorizontalPosition){case"right":return"center"===r.options.legendVerticalPosition||"middle"===r.options.legendVerticalPosition?t+r.options.legendMargin[3]:t-a.getDim("width")-r.options.legendMargin[1];case"middle":case"center":return Math.round(t/2-a.getDim("width")/2);default:return r.options.legendMargin[3]}}function o(){switch(r.options.legendVerticalPosition){case"center":case"middle":case"top":return r.options.legendMargin[0];case"bottom":return r.graphDim.height+r.options.legendMargin[0]}}var i,a=this,r=this.calendar,s=r.root;this.computeDim();var l=r.options.legend.slice(0);l.push(l[l.length-1]+1);var m=r.root.select(".graph-legend");null!==m[0][0]?(s=m,i=s.select("g").selectAll("rect").data(l)):(s="top"===r.options.legendVerticalPosition?s.insert("svg",".graph"):s.append("svg"),s.attr("x",n()).attr("y",o()),i=s.attr("class","graph-legend").attr("height",a.getDim("height")).attr("width",a.getDim("width")).append("g").selectAll().data(l)),i.enter().append("rect").call(e).attr("class",function(t){return r.Legend.getClass(t,null===r.legendScale)}).attr("fill-opacity",0).call(function(t){null!==r.legendScale&&null!==r.options.legendColors&&r.options.legendColors.hasOwnProperty("base")&&t.attr("fill",r.options.legendColors.base)}).append("title"),i.exit().transition().duration(r.options.animationDuration).attr("fill-opacity",0).remove(),i.transition().delay(function(t,e){return r.options.animationDuration*e/10}).call(e).attr("fill-opacity",1).call(function(t){t.attr("fill",function(t,e){return null===r.legendScale?"":0===e?r.legendScale(t-1):r.legendScale(r.options.legend[e-1])}),t.attr("class",function(t){return r.Legend.getClass(t,null===r.legendScale)})}),i.select("title").text(function(t,e){return 0===e?r.options.legendTitleFormat.lower.format({min:r.options.legend[e],name:r.options.itemName[1]}):e===l.length-1?r.options.legendTitleFormat.upper.format({max:r.options.legend[e-1],name:r.options.itemName[1]}):r.options.legendTitleFormat.inner.format({down:r.options.legend[e-1],up:r.options.legend[e],name:r.options.itemName[1]})}),s.transition().duration(r.options.animationDuration).attr("x",n()).attr("y",o()).attr("width",a.getDim("width")).attr("height",a.getDim("height")),s.select("g").transition().duration(r.options.animationDuration).attr("transform",function(){return"vertical"===r.options.legendOrientation?"rotate(90 "+r.options.legendCellSize/2+" "+r.options.legendCellSize/2+")":""}),r.resize()},Legend.prototype.getDim=function(t){switch(t){case"width":return this.dim["horizontal"===this.calendar.options.legendOrientation?"width":"height"];case"height":return this.dim["horizontal"===this.calendar.options.legendOrientation?"height":"width"]}},Legend.prototype.buildColors=function(){if(null===this.calendar.options.legendColors)return this.calendar.legendScale=null,!1;var t=[];if(Array.isArray(this.calendar.options.legendColors))t=this.calendar.options.legendColors;else{if(!this.calendar.options.legendColors.hasOwnProperty("min")||!this.calendar.options.legendColors.hasOwnProperty("max"))return this.calendar.options.legendColors=null,!1;t=[this.calendar.options.legendColors.min,this.calendar.options.legendColors.max]}var e=this.calendar.options.legend.slice(0);e[0]>0?e.unshift(0):0>e[0]&&e.unshift(e[0]-(e[e.length-1]-e[0])/e.length);var n=d3.scale.linear().range(t).interpolate(d3.interpolateHcl).domain([d3.min(e),d3.max(e)]),o=e.map(function(t){return n(t)});return this.calendar.legendScale=d3.scale.threshold().domain(this.calendar.options.legend).range(o),!0},Legend.prototype.getClass=function(t,e){if(null===t||isNaN(t))return"";for(var n=[this.calendar.options.legend.length+1],o=0,i=this.calendar.options.legend.length-1;i>=o;o++){if(this.calendar.options.legend[0]>0&&0>t){n=["1","i"];break}if(this.calendar.options.legend[o]>=t){n=[o+1];break}}return 0===t&&n.push(0),n.unshift(""),(n.join(" r")+(e?n.join(" q"):"")).trim()},String.prototype.format=function(){var t=this;for(var e in arguments[0]){var n=RegExp("\\{"+e+"\\}","gi");t=t.replace(n,arguments[0][e])}return t},"function"==typeof define&&define.amd&&define(["d3"],function(){return CalHeatMap}); +function mergeRecursive(t,e){"use strict";for(var n in e)try{t[n]=e[n].constructor===Object?mergeRecursive(t[n],e[n]):e[n]}catch(i){t[n]=e[n]}return t}function arrayEquals(t,e){"use strict";if(!e||!t)return!1;if(t.length!==e.length)return!1;for(var n=0;t.length>n;n++)if(t[n]instanceof Array&&e[n]instanceof Array){if(!arrayEquals(t[n],e[n]))return!1}else if(t[n]!==e[n])return!1;return!0}var CalHeatMap=function(){"use strict";function t(){i.verticalDomainLabel="top"===i.options.label.position||"bottom"===i.options.label.position,i.domainVerticalLabelHeight=null===i.options.label.height?Math.max(25,2*i.options.cellSize):i.options.label.height,i.domainHorizontalLabelWidth=0,""===i.options.domainLabelFormat&&null===i.options.label.height&&(i.domainVerticalLabelHeight=0),i.verticalDomainLabel||(i.domainVerticalLabelHeight=0,i.domainHorizontalLabelWidth=i.options.label.width),i.paint(),i.options.nextSelector!==!1&&d3.select(i.options.nextSelector).on("click."+i.options.itemNamespace,function(){return d3.event.preventDefault(),i.loadNextDomain(1)}),i.options.previousSelector!==!1&&d3.select(i.options.previousSelector).on("click."+i.options.itemNamespace,function(){return d3.event.preventDefault(),i.loadPreviousDomain(1)}),i.Legend.redraw(i.graphDim.width-i.options.domainGutter-i.options.cellPadding),i.afterLoad();var t=i.getDomainKeys();i.options.loadOnInit?i.getDatas(i.options.data,new Date(t[0]),i.getSubDomain(t[t.length-1]).pop(),function(){i.fill(),i.onComplete()}):i.onComplete(),i.checkIfMinDomainIsReached(t[0]),i.checkIfMaxDomainIsReached(i.getNextDomain().getTime())}function e(t,e){var n=i.options.cellSize*i._domainType[i.options.subDomain].column(t)+i.options.cellPadding*i._domainType[i.options.subDomain].column(t);return 2===arguments.length&&e===!0?n+=i.domainHorizontalLabelWidth+i.options.domainGutter+i.options.domainMargin[1]+i.options.domainMargin[3]:n}function n(t,e){var n=i.options.cellSize*i._domainType[i.options.subDomain].row(t)+i.options.cellPadding*i._domainType[i.options.subDomain].row(t);return 2===arguments.length&&e===!0&&(n+=i.options.domainGutter+i.domainVerticalLabelHeight+i.options.domainMargin[0]+i.options.domainMargin[2]),n}var i=this;this.allowedDataType=["json","csv","tsv","txt"],this.options={itemSelector:"#cal-heatmap",paintOnLoad:!0,range:12,cellSize:10,cellPadding:2,cellRadius:0,domainGutter:2,domainMargin:[0,0,0,0],domain:"hour",subDomain:"min",colLimit:null,rowLimit:null,weekStartOnMonday:!0,start:new Date,minDate:null,maxDate:null,data:"",dataType:this.allowedDataType[0],considerMissingDataAsZero:!1,loadOnInit:!0,verticalOrientation:!1,domainDynamicDimension:!0,label:{position:"bottom",align:"center",offset:{x:0,y:0},rotate:null,width:100,height:null},legend:[10,20,30,40],displayLegend:!0,legendCellSize:10,legendCellPadding:2,legendMargin:[0,0,0,0],legendVerticalPosition:"bottom",legendHorizontalPosition:"left",legendOrientation:"horizontal",legendColors:null,highlight:[],itemName:["item","items"],domainLabelFormat:null,subDomainTitleFormat:{empty:"{date}",filled:"{count} {name} {connector} {date}"},subDomainDateFormat:null,subDomainTextFormat:null,legendTitleFormat:{lower:"less than {min} {name}",inner:"between {down} and {up} {name}",upper:"more than {max} {name}"},animationDuration:500,nextSelector:!1,previousSelector:!1,itemNamespace:"cal-heatmap",tooltip:!1,onClick:null,afterLoad:null,afterLoadNextDomain:null,afterLoadPreviousDomain:null,onComplete:null,afterLoadData:function(t){return t},onMaxDomainReached:null,onMinDomainReached:null},this._domainType={min:{name:"minute",level:10,row:function(){return i.options.colLimit>0?Math.ceil(60/i.options.colLimit):i.options.rowLimit||10},column:function(){return i.options.rowLimit>0?Math.ceil(60/i.options.rowLimit):i.options.colLimit||6},position:{x:function(t){return Math.floor(t.getMinutes()/i._domainType.min.row(t))},y:function(t){return t.getMinutes()%i._domainType.min.row(t)}},format:{date:"%H:%M, %A %B %-e, %Y",legend:"",connector:"at"},extractUnit:function(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes()).getTime()}},hour:{name:"hour",level:20,row:function(t){if(i.options.colLimit>0){var e=24;return"week"===i.options.domain?e=168:"month"===i.options.domain&&(e=24*i.getDayCountInMonth(t)),Math.ceil(e/i.options.colLimit)}return i.options.rowLimit||6},column:function(t){if(i.options.colLimit>0)return i.options.colLimit;switch(i.options.domain){case"day":return i.options.rowLimit>0?Math.ceil(24/i.options.rowLimit):4;case"week":return i.options.rowLimit>0?Math.ceil(168/i.options.rowLimit):28;case"month":return i.options.rowLimit>0?Math.ceil(744/i.options.rowLimit):4*(i.options.domainDynamicDimension?i.getEndOfMonth(t).getDate():31)}},position:{x:function(t){return"month"===i.options.domain?i.options.colLimit>0||i.options.rowLimit>0?Math.floor((t.getHours()+24*(t.getDate()-1))/i._domainType.hour.row(t)):Math.floor(t.getHours()/i._domainType.hour.row(t))+4*(t.getDate()-1):"week"===i.options.domain?i.options.colLimit>0||i.options.rowLimit>0?Math.floor((t.getHours()+24*i.getWeekDay(t))/i._domainType.hour.row(t)):Math.floor(t.getHours()/i._domainType.hour.row(t))+4*i.getWeekDay(t):Math.floor(t.getHours()/i._domainType.hour.row(t))},y:function(t){if(i.options.colLimit>0||i.options.rowLimit>0)switch(i.options.domain){case"month":return Math.floor((t.getHours()+24*(t.getDate()-1))%i._domainType.hour.row(t));case"week":return Math.floor((t.getHours()+24*i.getWeekDay(t))%i._domainType.hour.row(t))}return t.getHours()%i._domainType.hour.row(t)}},format:{date:"%Hh, %A %B %-e, %Y",legend:"%H:00",connector:"at"},extractUnit:function(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours()).getTime()}},day:{name:"day",level:30,row:function(t){if(i.options.colLimit>0){var e=0;switch(i.options.domain){case"year":e=i.getDayCountInYear(t);break;case"month":e=i.getDayCountInMonth(t);break;case"week":e=7}return Math.ceil(e/i.options.colLimit)}return i.options.rowLimit||7},column:function(t){if(i.options.colLimit>0)return i.options.colLimit;switch(t=new Date(t),i.options.domain){case"year":if(i.options.rowLimit>0){var e=i.options.domainDynamicDimension?i.getDayCountInYear(t):366;return Math.ceil(e/i.options.rowLimit)}return i.options.domainDynamicDimension?i.getWeekNumber(new Date(t.getFullYear(),11,31))-i.getWeekNumber(new Date(t.getFullYear(),0))+1:54;case"month":if(i.options.rowLimit>0){var n=i.options.domainDynamicDimension?new Date(t.getFullYear(),t.getMonth()+1,0).getDate():31;return Math.ceil(n/i.options.rowLimit)}return i.options.verticalOrientation?6:i.options.domainDynamicDimension?i.getWeekNumber(new Date(t.getFullYear(),t.getMonth()+1,0))-i.getWeekNumber(t)+1:6;case"week":return Math.ceil(7/i._domainType.day.row(t))}},position:{x:function(t){switch(i.options.domain){case"week":return Math.floor(i.getWeekDay(t)/i._domainType.day.row(t));case"month":return i.options.colLimit>0||i.options.rowLimit>0?Math.floor((t.getDate()-1)/i._domainType.day.row(t)):i.getWeekNumber(t)-i.getWeekNumber(new Date(t.getFullYear(),t.getMonth()));case"year":return i.options.colLimit>0||i.options.rowLimit>0?Math.floor((i.getDayOfYear(t)-1)/i._domainType.day.row(t)):i.getWeekNumber(t)}},y:function(t){if(i.options.colLimit>0||i.options.rowLimit>0)switch(i.options.domain){case"year":return Math.floor((i.getDayOfYear(t)-1)%i._domainType.day.row(t));case"week":return Math.floor(i.getWeekDay(t)%i._domainType.day.row(t));case"month":return Math.floor((t.getDate()-1)%i._domainType.day.row(t))}return i.getWeekDay(t)%i._domainType.day.row(t)}},format:{date:"%A %B %-e, %Y",legend:"%e %b",connector:"on"},extractUnit:function(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()}},week:{name:"week",level:40,row:function(){return i.options.colLimit>0?Math.ceil(54/i.options.colLimit):i.options.rowLimit||1},column:function(t){if(i.options.colLimit>0)return i.options.colLimit;switch(t=new Date(t),i.options.domain){case"year":return 54;case"month":return i.getWeekNumber(new Date(t.getFullYear(),t.getMonth()+1,0))-i.getWeekNumber(t);default:return 1}},position:{x:function(t){switch(i.options.domain){case"year":return i.options.colLimit>0||i.options.rowLimit>0?Math.floor(i.getWeekNumber(t)/i._domainType.week.row(t)):i.getWeekNumber(t);case"month":var e=i.getMonthWeekNumber(t);return i.options.colLimit>0||i.options.rowLimit>0?Math.floor((e-1)/i._domainType.week.row(t)):e}},y:function(t){return i.getWeekNumber(t)%i._domainType.week.row(t)}},format:{date:"%B Week #%W",legend:"%B Week #%W",connector:"on"},extractUnit:function(t){var e=new Date(t.getFullYear(),t.getMonth(),t.getDate()),n=e.getDay()-1;return 0>n&&(n=6),e.setDate(e.getDate()-n),e.getTime()}},month:{name:"month",level:50,row:function(){return i.options.colLimit>0?Math.ceil(12/i.options.colLimit):i.options.rowLimit||1},column:function(){return i.options.rowLimit>0?Math.ceil(12/i.options.rowLimit):i.options.colLimit||12},position:{x:function(t){return Math.floor(t.getMonth()/i._domainType.month.row(t))},y:function(t){return t.getMonth()%i._domainType.month.row(t)}},format:{date:"%B %Y",legend:"%B",connector:"on"},extractUnit:function(t){return new Date(t.getFullYear(),t.getMonth()).getTime()}},year:{name:"year",level:60,row:function(){return i.options.rowLimit||1},column:function(){return i.options.colLimit||1},position:{x:function(){return 1},y:function(){return 1}},format:{date:"%Y",legend:"%Y",connector:"on"},extractUnit:function(t){return new Date(t.getFullYear()).getTime()}}};for(var o in this._domainType)this._domainType.hasOwnProperty(o)&&(this._domainType["x_"+o]={},this._domainType["x_"+o].name="x_"+o,this._domainType["x_"+o].level=this._domainType[o].level,this._domainType["x_"+o].row=this._domainType[o].column,this._domainType["x_"+o].column=this._domainType[o].row,this._domainType["x_"+o].position={},this._domainType["x_"+o].position.x=this._domainType[o].position.y,this._domainType["x_"+o].position.y=this._domainType[o].position.x,this._domainType["x_"+o].format=this._domainType[o].format,this._domainType["x_"+o].extractUnit=this._domainType[o].extractUnit);this._domainType.x_day.row=function(t){switch(t=new Date(t),i.options.domain){case"year":return i.options.domainDynamicDimension?i.getWeekNumber(new Date(t.getFullYear(),11,31))-i.getWeekNumber(new Date(t.getFullYear(),0))+1:54;case"month":return i.options.verticalOrientation?i.options.domainDynamicDimension?i.getWeekNumber(new Date(t.getFullYear(),t.getMonth()+1,0))-i.getWeekNumber(t)+1:6:6;case"week":return 1}},this.lastInsertedSvg=null,this._completed=!1,this._domains=d3.map(),this.graphDim={width:0,height:0},this.legendDim={width:0,height:0},this.NAVIGATE_LEFT=1,this.NAVIGATE_RIGHT=2,this.RESET_ALL_ON_UPDATE=0,this.RESET_SINGLE_ON_UPDATE=1,this.APPEND_ON_UPDATE=2,this.DEFAULT_LEGEND_MARGIN=10,this.root=null,this.tooltip=null,this._maxDomainReached=!1,this._minDomainReached=!1,this.domainPosition=new DomainPosition,this.Legend=null,this.legendScale=null,this._init=function(){return i.getDomain(i.options.start).map(function(t){return t.getTime()}).map(function(t){i._domains.set(t,i.getSubDomain(t).map(function(t){return{t:i._domainType[i.options.subDomain].extractUnit(t),v:null}}))}),i.root=d3.select(i.options.itemSelector).append("svg").attr("class","cal-heatmap-container"),i.tooltip=d3.select(i.options.itemSelector).attr("style",d3.select(i.options.itemSelector).attr("style")+"position:relative;").append("div").attr("class","ch-tooltip"),i.root.attr("x",0).attr("y",0).append("svg").attr("class","graph"),i.Legend=new Legend(i),i.options.paintOnLoad&&t(),!0},this.paint=function(t){function o(e,n,o,a){var r=0;switch(t){case!1:return r=n[o],n[o]+=a,i.domainPosition.setPosition(e,r),r;case i.NAVIGATE_RIGHT:return i.domainPosition.setPosition(e,n[o]),l=a,u=i.domainPosition.getPositionFromIndex(1),i.domainPosition.shiftRightBy(u),n[o];case i.NAVIGATE_LEFT:return r=-a,l=-r,u=n[o]-i.domainPosition.getLast(),i.domainPosition.setPosition(e,r),i.domainPosition.shiftLeftBy(l),r}}function a(t){switch(r.label.rotate){case"right":t.attr("transform",function(t){var n="rotate(90), ";switch(r.label.position){case"right":n+="translate(-"+e(t)+" , -"+e(t)+")";break;case"left":n+="translate(0, -"+i.domainHorizontalLabelWidth+")"}return n});break;case"left":t.attr("transform",function(t){var n="rotate(270), ";switch(r.label.position){case"right":n+="translate(-"+(e(t)+i.domainHorizontalLabelWidth)+" , "+e(t)+")";break;case"left":n+="translate(-"+i.domainHorizontalLabelWidth+" , "+i.domainHorizontalLabelWidth+")"}return n})}}var r=i.options;0===arguments.length&&(t=!1);var s=i.root.select(".graph").selectAll(".graph-domain").data(function(){var e=i.getDomainKeys();return t===i.NAVIGATE_LEFT?e.reverse():e},function(t){return t}),l=0,u=0,c=s.enter().append("svg").attr("width",function(t){return e(t,!0)}).attr("height",function(t){return n(t,!0)}).attr("x",function(t){return r.verticalOrientation?(i.graphDim.width=e(t,!0),0):o(t,i.graphDim,"width",e(t,!0))}).attr("y",function(t){return r.verticalOrientation?o(t,i.graphDim,"height",n(t,!0)):(i.graphDim.height=n(t,!0),0)}).attr("class",function(t){var e="graph-domain",n=new Date(t);switch(r.domain){case"hour":e+=" h_"+n.getHours();case"day":e+=" d_"+n.getDate()+" dy_"+n.getDay();case"week":e+=" w_"+i.getWeekNumber(n);case"month":e+=" m_"+(n.getMonth()+1);case"year":e+=" y_"+n.getFullYear()}return e});i.lastInsertedSvg=c,c.append("rect").attr("width",function(t){return e(t,!0)-r.domainGutter-r.cellPadding}).attr("height",function(t){return n(t,!0)-r.domainGutter-r.cellPadding}).attr("class","domain-background");var m=c.append("svg").attr("x",function(){return"left"===r.label.position?i.domainHorizontalLabelWidth+r.domainMargin[3]:r.domainMargin[3]}).attr("y",function(){return"top"===r.label.position?i.domainVerticalLabelHeight+r.domainMargin[0]:r.domainMargin[0]}).attr("class","graph-subdomain-group"),h=m.selectAll("g").data(function(t){return i._domains.get(t)}).enter().append("g");h.append("rect").attr("class",function(t){return"graph-rect"+i.getHighlightClassName(t.t)+(null!==r.onClick?" hover_cursor":"")}).attr("width",r.cellSize).attr("height",r.cellSize).attr("x",function(t){return i.positionSubDomainX(t.t)}).attr("y",function(t){return i.positionSubDomainY(t.t)}).on("click",function(t){return null!==r.onClick?i.onClick(new Date(t.t),t.v):void 0}).call(function(t){r.cellRadius>0&&t.attr("rx",r.cellRadius).attr("ry",r.cellRadius),null!==i.legendScale&&null!==r.legendColors&&r.legendColors.hasOwnProperty("base")&&t.attr("fill",r.legendColors.base),r.tooltip&&(t.on("mouseover",function(t){var e=this.parentNode.parentNode.parentNode;i.tooltip.html(i.getSubDomainTitle(t)).attr("style","display: block;"),i.tooltip.attr("style","display: block; left: "+(i.positionSubDomainX(t.t)-i.tooltip[0][0].offsetWidth/2+r.cellSize/2+parseInt(e.getAttribute("x"),10))+"px; "+"top: "+(i.positionSubDomainY(t.t)-i.tooltip[0][0].offsetHeight-r.cellSize/2+parseInt(e.getAttribute("y"),10))+"px;")}),t.on("mouseout",function(){i.tooltip.attr("style","display:none").html("")}))}),r.tooltip||h.append("title").text(function(t){return i.formatDate(new Date(t.t),r.subDomainDateFormat)}),""!==r.domainLabelFormat&&c.append("text").attr("class","graph-label").attr("y",function(t){var e=r.domainMargin[0];switch(r.label.position){case"top":e+=i.domainVerticalLabelHeight/2;break;case"bottom":e+=n(t)+i.domainVerticalLabelHeight/2}return e+r.label.offset.y*("right"===r.label.rotate&&"right"===r.label.position||"left"===r.label.rotate&&"left"===r.label.position?-1:1)}).attr("x",function(t){var n=r.domainMargin[3];switch(r.label.position){case"right":n+=e(t);break;case"bottom":case"top":n+=e(t)/2}return"right"===r.label.align?n+i.domainHorizontalLabelWidth-r.label.offset.x*("right"===r.label.rotate?-1:1):n+r.label.offset.x}).attr("text-anchor",function(){switch(r.label.align){case"start":case"left":return"start";case"end":case"right":return"end";default:return"middle"}}).attr("dominant-baseline",function(){return i.verticalDomainLabel?"middle":"top"}).text(function(t){return i.formatDate(new Date(t),r.domainLabelFormat)}).call(a),null!==r.subDomainTextFormat&&h.append("text").attr("class",function(t){return"subdomain-text"+i.getHighlightClassName(t.t)}).attr("x",function(t){return i.positionSubDomainX(t.t)+r.cellSize/2}).attr("y",function(t){return i.positionSubDomainY(t.t)+r.cellSize/2}).attr("text-anchor","middle").attr("dominant-baseline","central").text(function(t){return i.formatDate(new Date(t.t),r.subDomainTextFormat)}),t!==!1&&s.transition().duration(r.animationDuration).attr("x",function(t){return r.verticalOrientation?0:i.domainPosition.getPosition(t)}).attr("y",function(t){return r.verticalOrientation?i.domainPosition.getPosition(t):0});var g=i.graphDim.width,d=i.graphDim.height;r.verticalOrientation?i.graphDim.height+=l-u:i.graphDim.width+=l-u,s.exit().transition().duration(r.animationDuration).attr("x",function(n){if(r.verticalOrientation)return 0;switch(t){case i.NAVIGATE_LEFT:return Math.min(i.graphDim.width,g);case i.NAVIGATE_RIGHT:return-e(n,!0)}}).attr("y",function(e){if(!r.verticalOrientation)return 0;switch(t){case i.NAVIGATE_LEFT:return Math.min(i.graphDim.height,d);case i.NAVIGATE_RIGHT:return-n(e,!0)}}).remove(),i.resize()}};CalHeatMap.prototype={init:function(t){"use strict";function e(t,e,n){if((e&&t===!1||t instanceof Element||"string"==typeof t)&&""!==t)return!0;throw Error("The "+n+" is not valid")}function n(t){switch(t){case"year":return"month";case"month":return"day";case"week":return"day";case"day":return"hour";default:return"min"}}function i(){if(!c._domainType.hasOwnProperty(m.domain)||"min"===m.domain||"x_"===m.domain.substring(0,2))throw Error("The domain '"+m.domain+"' is not valid");if(!c._domainType.hasOwnProperty(m.subDomain)||"year"===m.subDomain)throw Error("The subDomain '"+m.subDomain+"' is not valid");if(c._domainType[m.domain].level<=c._domainType[m.subDomain].level)throw Error("'"+m.subDomain+"' is not a valid subDomain to '"+m.domain+"'");return!0}function o(){if(!t.hasOwnProperty("label")||t.hasOwnProperty("label")&&!t.label.hasOwnProperty("align")){switch(m.label.position){case"left":m.label.align="right";break;case"right":m.label.align="left";break;default:m.label.align="center"}"left"===m.label.rotate?m.label.align="right":"right"===m.label.rotate&&(m.label.align="left")}(!t.hasOwnProperty("label")||t.hasOwnProperty("label")&&!t.label.hasOwnProperty("offset"))&&("left"===m.label.position||"right"===m.label.position)&&(m.label.offset={x:10,y:15})}function a(){switch(m.legendVerticalPosition){case"top":m.legendMargin[2]=c.DEFAULT_LEGEND_MARGIN;break;case"bottom":m.legendMargin[0]=c.DEFAULT_LEGEND_MARGIN;break;case"middle":case"center":m.legendMargin["right"===m.legendHorizontalPosition?3:1]=c.DEFAULT_LEGEND_MARGIN}}function r(t){switch("number"==typeof t&&(t=[t]),Array.isArray(t)||(console.log("Margin only takes an integer or an array of integers"),t=[0]),t.length){case 0:return[0,0,0,0];case 1:return[t[0],t[0],t[0],t[0]];case 2:return[t[0],t[1],t[0],t[1]];case 3:return[t[0],t[1],t[2],t[1]];case 4:return t;default:return t.slice(0,4)}}function s(t){return"string"==typeof t?[t,t+(""!==t?"s":"")]:Array.isArray(t)?1===t.length?[t[0],t[0]+"s"]:t.length>2?t.slice(0,2):t:["item","items"]}function l(t){return t>0?t:null}function u(t){return t>0&&m.colLimit>0?(console.log("colLimit and rowLimit are mutually exclusive, rowLimit will be ignored"),null):t>0?t:null}var c=this;c.options=mergeRecursive(c.options,t);var m=c.options;if(i(),e(m.itemSelector,!1,"itemSelector"),0>c.allowedDataType.indexOf(m.dataType))throw Error("The data type '"+m.dataType+"' is not valid data type");if(null===d3.select(m.itemSelector)[0][0])throw Error("The node '"+m.itemSelector+"' specified in itemSelector does not exists");try{e(m.nextSelector,!0,"nextSelector"),e(m.previousSelector,!0,"previousSelector")}catch(h){return console.log(h.message),!1}t.hasOwnProperty("subDomain")||(this.options.subDomain=n(t.domain)),("string"!=typeof m.itemNamespace||""===m.itemNamespace)&&(console.log("itemNamespace can not be empty, falling back to cal-heatmap"),m.itemNamespace="cal-heatmap");var g=["data","onComplete","onClick","afterLoad","afterLoadData","afterLoadPreviousDomain","afterLoadNextDomain"];for(var d in g)t.hasOwnProperty(g[d])&&(m[g[d]]=t[g[d]]);return m.subDomainDateFormat="string"==typeof m.subDomainDateFormat||"function"==typeof m.subDomainDateFormat?m.subDomainDateFormat:this._domainType[m.subDomain].format.date,m.domainLabelFormat="string"==typeof m.domainLabelFormat||"function"==typeof m.domainLabelFormat?m.domainLabelFormat:this._domainType[m.domain].format.legend,m.subDomainTextFormat="string"==typeof m.subDomainTextFormat&&""!==m.subDomainTextFormat||"function"==typeof m.subDomainTextFormat?m.subDomainTextFormat:null,m.domainMargin=r(m.domainMargin),m.legendMargin=r(m.legendMargin),m.highlight=c.expandDateSetting(m.highlight),m.itemName=s(m.itemName),m.colLimit=l(m.colLimit),m.rowLimit=u(m.rowLimit),t.hasOwnProperty("legendMargin")||a(),o(),this._init()},expandDateSetting:function(t){"use strict";return Array.isArray(t)||(t=[t]),t.map(function(t){return"now"===t?new Date:t instanceof Date?t:!1}).filter(function(t){return t!==!1})},fill:function(t){"use strict";function e(t){return null===n.legendScale?!1:(t.attr("fill",function(t){return 0===t.v&&null!==i.legendColors&&i.legendColors.hasOwnProperty("empty")?i.legendColors.empty:0>t.v&&i.legend[0]>0&&null!==i.legendColors&&i.legendColors.hasOwnProperty("overflow")?i.legendColors.overflow:n.legendScale(Math.min(t.v,i.legend[i.legend.length-2]))}),void 0)}var n=this,i=n.options;0===arguments.length&&(t=n.root.selectAll(".graph-domain"));var o=t.selectAll("svg").selectAll("g").data(function(t){return n._domains.get(t)});o.transition().duration(i.animationDuration).select("rect").attr("class",function(t){var e=n.getHighlightClassName(t.t);return null===n.legendScale&&(e+=" graph-rect"),null!==t.v?e+=" "+n.Legend.getClass(t.v,null===n.legendScale):i.considerMissingDataAsZero&&(e+=" "+n.Legend.getClass(0,null===n.legendScale)),null!==i.onClick&&(e+=" hover_cursor"),e}).call(e),o.transition().duration(i.animationDuration).select("title").text(function(t){return n.getSubDomainTitle(t)})},triggerEvent:function(t,e,n){"use strict";return 3===arguments.length&&n||null===this.options[t]?!0:"function"==typeof this.options[t]?("function"==typeof e&&(e=e()),this.options[t].apply(this,e)):(console.log("Provided callback for "+t+" is not a function."),!1)},onClick:function(t,e){"use strict";return this.triggerEvent("onClick",[t,e])},afterLoad:function(){"use strict";return this.triggerEvent("afterLoad")},onComplete:function(){"use strict";var t=this.triggerEvent("onComplete",[],this._completed);return this._completed=!0,t},afterLoadPreviousDomain:function(t){"use strict";var e=this;return this.triggerEvent("afterLoadPreviousDomain",function(){var n=e.getSubDomain(t);return[n.shift(),n.pop()]})},afterLoadNextDomain:function(t){"use strict";var e=this;return this.triggerEvent("afterLoadNextDomain",function(){var n=e.getSubDomain(t);return[n.shift(),n.pop()]})},onMinDomainReached:function(t){"use strict";return this._minDomainReached=t,this.triggerEvent("onMinDomainReached",[t])},onMaxDomainReached:function(t){"use strict";return this._maxDomainReached=t,this.triggerEvent("onMaxDomainReached",[t])},checkIfMinDomainIsReached:function(t,e){"use strict";this.minDomainIsReached(t)&&this.onMinDomainReached(!0),2===arguments.length&&this._maxDomainReached&&!this.maxDomainIsReached(e)&&this.onMaxDomainReached(!1)},checkIfMaxDomainIsReached:function(t,e){"use strict";this.maxDomainIsReached(t)&&this.onMaxDomainReached(!0),2===arguments.length&&this._minDomainReached&&!this.minDomainIsReached(e)&&this.onMinDomainReached(!1)},formatNumber:d3.format(",g"),formatDate:function(t,e){"use strict";if(2>arguments.length&&(e="title"),"function"==typeof e)return e(t);var n=d3.time.format(e);return n(t)},getSubDomainTitle:function(t){"use strict";if(null!==t.v||this.options.considerMissingDataAsZero){var e=t.v;return null===e&&this.options.considerMissingDataAsZero&&(e=0),this.options.subDomainTitleFormat.filled.format({count:this.formatNumber(e),name:this.options.itemName[1!==e?1:0],connector:this._domainType[this.options.subDomain].format.connector,date:this.formatDate(new Date(t.t),this.options.subDomainDateFormat)})}return this.options.subDomainTitleFormat.empty.format({date:this.formatDate(new Date(t.t),this.options.subDomainDateFormat)})},loadNextDomain:function(t){"use strict";if(this._maxDomainReached||0===t)return!1;var e=this.loadNewDomains(this.NAVIGATE_RIGHT,this.getDomain(this.getNextDomain(),t));return this.afterLoadNextDomain(e.end),this.checkIfMaxDomainIsReached(this.getNextDomain().getTime(),e.start),!0},loadPreviousDomain:function(t){"use strict";if(this._minDomainReached||0===t)return!1;var e=this.loadNewDomains(this.NAVIGATE_LEFT,this.getDomain(this.getDomainKeys()[0],-t).reverse());return this.afterLoadPreviousDomain(e.start),this.checkIfMinDomainIsReached(e.start,e.end),!0},loadNewDomains:function(t,e){"use strict";function n(t){return{t:i._domainType[i.options.subDomain].extractUnit(t),v:null}}for(var i=this,o=t===this.NAVIGATE_LEFT,a=-1,r=e.length,s=this.getDomainKeys();r>++a;){if(o&&this.minDomainIsReached(e[a])){e=e.slice(0,a+1);break}if(!o&&this.maxDomainIsReached(e[a])){e=e.slice(0,a);break}}for(e=e.slice(-this.options.range),a=0,r=e.length;r>a;a++)this._domains.set(e[a].getTime(),this.getSubDomain(e[a]).map(n)),this._domains.remove(o?s.pop():s.shift());return s=this.getDomainKeys(),o&&(e=e.reverse()),this.paint(t),this.getDatas(this.options.data,e[0],this.getSubDomain(e[e.length-1]).pop(),function(){i.fill(i.lastInsertedSvg)}),{start:e[o?0:1],end:s[s.length-1]}},maxDomainIsReached:function(t){"use strict";return null!==this.options.maxDate&&t>this.options.maxDate.getTime()},minDomainIsReached:function(t){"use strict";return null!==this.options.minDate&&this.options.minDate.getTime()>=t},getDomainKeys:function(){"use strict";return this._domains.keys().map(function(t){return parseInt(t,10)}).sort(function(t,e){return t-e})},positionSubDomainX:function(t){"use strict";var e=this._domainType[this.options.subDomain].position.x(new Date(t));return e*this.options.cellSize+e*this.options.cellPadding},positionSubDomainY:function(t){"use strict";var e=this._domainType[this.options.subDomain].position.y(new Date(t));return e*this.options.cellSize+e*this.options.cellPadding},getHighlightClassName:function(t){"use strict";if(t=new Date(t),this.options.highlight.length>0)for(var e in this.options.highlight)if(this.options.highlight[e]instanceof Date&&this.dateIsEqual(this.options.highlight[e],t))return" highlight"+(this.isNow(this.options.highlight[e])?" now":"");return""},isNow:function(t){"use strict";return this.dateIsEqual(t,new Date)},dateIsEqual:function(t,e){"use strict";switch(this.options.subDomain){case"x_min":case"min":return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()&&t.getHours()===e.getHours()&&t.getMinutes()===e.getMinutes();case"x_hour":case"hour":return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()&&t.getHours()===e.getHours();case"x_day":case"day":return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate();case"x_week":case"week":case"x_month":case"month":return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth();default:return!1}},getDayOfYear:d3.time.format("%j"),getWeekNumber:function(t){"use strict";var e=this.options.weekStartOnMonday===!0?d3.time.format("%W"):d3.time.format("%U");return e(t)},getMonthWeekNumber:function(t){"use strict";"number"==typeof t&&(t=new Date(t));var e=this.getWeekNumber(new Date(t.getFullYear(),t.getMonth()));return this.getWeekNumber(t)-e-1},getWeekNumberInYear:function(t){"use strict";"number"==typeof t&&(t=new Date(t))},getDayCountInMonth:function(t){"use strict";return this.getEndOfMonth(t).getDate()},getDayCountInYear:function(t){"use strict";return"number"==typeof t&&(t=new Date(t)),0===t.getFullYear()%400?366:365},getWeekDay:function(t){"use strict";return this.options.weekStartOnMonday===!1?t.getDay():0===t.getDay()?6:t.getDay()-1},getEndOfMonth:function(t){"use strict";return"number"==typeof t&&(t=new Date(t)),new Date(t.getFullYear(),t.getMonth()+1,0)},jumpDate:function(t,e,n){"use strict";var i=new Date(t);switch(n){case"hour":i.setHours(i.getHours()+e);break;case"day":i.setHours(i.getHours()+24*e);break;case"week":i.setHours(i.getHours()+7*24*e);break;case"month":i.setMonth(i.getMonth()+e);break;case"year":i.setFullYear(i.getFullYear()+e)}return new Date(i)},getMinuteDomain:function(t,e){"use strict";var n=new Date(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours()),i=null;return i=e instanceof Date?new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours()):new Date(n.getTime()+6e4*e),d3.time.minutes(Math.min(n,i),Math.max(n,i))},getHourDomain:function(t,e){"use strict";var n=new Date(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours()),i=null;return i=e instanceof Date?new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours()):new Date(n.getTime()+36e5*e),d3.time.hours(Math.min(n,i),Math.max(n,i))},getDayDomain:function(t,e){"use strict";var n=new Date(t.getFullYear(),t.getMonth(),t.getDate()),i=null;return e instanceof Date?i=new Date(e.getFullYear(),e.getMonth(),e.getDate()):(i=new Date(n),i=new Date(i.setDate(i.getDate()+parseInt(e,10)))),d3.time.days(Math.min(n,i),Math.max(n,i))},getWeekDomain:function(t,e){"use strict";var n;this.options.weekStartOnMonday===!1?n=new Date(t.getFullYear(),t.getMonth(),t.getDate()-t.getDay()):1===t.getDay()?n=new Date(t.getFullYear(),t.getMonth(),t.getDate()):0===t.getDay()?(n=new Date(t.getFullYear(),t.getMonth(),t.getDate()),n.setDate(n.getDate()-6)):n=new Date(t.getFullYear(),t.getMonth(),t.getDate()-t.getDay()+1);var i=new Date(n),o=e;return"object"!=typeof e&&(o=new Date(i.setDate(i.getDate()+7*e))),this.options.weekStartOnMonday===!0?d3.time.mondays(Math.min(n,o),Math.max(n,o)):d3.time.sundays(Math.min(n,o),Math.max(n,o))},getMonthDomain:function(t,e){"use strict";var n=new Date(t.getFullYear(),t.getMonth()),i=null;return e instanceof Date?i=new Date(e.getFullYear(),e.getMonth()):(i=new Date(n),i=i.setMonth(i.getMonth()+e)),d3.time.months(Math.min(n,i),Math.max(n,i))},getYearDomain:function(t,e){"use strict";var n=new Date(t.getFullYear(),0),i=null;return i=e instanceof Date?new Date(e.getFullYear(),0):new Date(t.getFullYear()+e,0),d3.time.years(Math.min(n,i),Math.max(n,i))},getDomain:function(t,e){"use strict";switch("number"==typeof t&&(t=new Date(t)),2>arguments.length&&(e=this.options.range),this.options.domain){case"hour":return this.getHourDomain(t,e);case"day":return this.getDayDomain(t,e);case"week":return this.getWeekDomain(t,e);case"month":return this.getMonthDomain(t,e);case"year":return this.getYearDomain(t,e)}},getSubDomain:function(t){"use strict";"number"==typeof t&&(t=new Date(t));var e=this,n=function(t,n){switch(n){case"year":return e.getDayCountInYear(t);case"month":return e.getDayCountInMonth(t);case"week":return 7}},i=function(t,e){switch(e){case"hour":return 60;case"day":return 1440;case"week":return 10080}},o=function(t,n){switch(n){case"day":return 24;case"week":return 168;case"month":return 24*e.getDayCountInMonth(t)}},a=function(t,n){if("month"===n){var i=new Date(t.getFullYear(),t.getMonth()+1,0),o=e.getWeekNumber(i),a=e.getWeekNumber(new Date(t.getFullYear(),t.getMonth()));return a>o&&(a=0,o++),o-a+1}return"year"===n?e.getWeekNumber(new Date(t.getFullYear(),11,31)):void 0};switch(this.options.subDomain){case"x_min":case"min":return this.getMinuteDomain(t,i(t,this.options.domain));case"x_hour":case"hour":return this.getHourDomain(t,o(t,this.options.domain));case"x_day":case"day":return this.getDayDomain(t,n(t,this.options.domain));case"x_week":case"week":return this.getWeekDomain(t,a(t,this.options.domain)); +case"x_month":case"month":return this.getMonthDomain(t,12)}},getNextDomain:function(t){"use strict";return 0===arguments.length&&(t=1),this.getDomain(this.jumpDate(this.getDomainKeys().pop(),t,this.options.domain),1)[0]},getPreviousDomain:function(t){"use strict";return 0===arguments.length&&(t=1),this.getDomain(this.jumpDate(this.getDomainKeys().shift(),-t,this.options.domain),1)[0]},getDatas:function(t,e,n,i,o,a){"use strict";var r=this;5>arguments.length&&(o=!0),6>arguments.length&&(a=this.APPEND_ON_UPDATE);var s=function(t){o!==!1?"function"==typeof o?t=o(t):"function"==typeof r.options.afterLoadData?t=r.options.afterLoadData(t):console.log("Provided callback for afterLoadData is not a function."):("csv"===r.options.dataType||"tsv"===r.options.dataType)&&(t=this.interpretCSV(t)),r.parseDatas(t,a,e,n),"function"==typeof i&&i()};switch(typeof t){case"string":if(""===t)return s({}),!0;switch(this.options.dataType){case"json":d3.json(this.parseURI(t,e,n),s);break;case"csv":d3.csv(this.parseURI(t,e,n),s);break;case"tsv":d3.tsv(this.parseURI(t,e,n),s);break;case"txt":d3.text(this.parseURI(t,e,n),"text/plain",s)}return!1;case"object":if(t===Object(t)&&"[object Array]"!==Object.prototype.toString.call(t))return s(t),!1;default:return s({}),!0}},parseDatas:function(t,e,n,i){"use strict";e===this.RESET_ALL_ON_UPDATE&&this._domains.forEach(function(t,e){e.forEach(function(t,e,n){n[e].v=null})});var o=this._domains.keys(),a=this._domains.get(o[0])[1].t-this._domains.get(o[0])[0].t;for(var r in t){var s=new Date(1e3*r),l=this.getDomain(s)[0].getTime();if(!isNaN(r)&&t.hasOwnProperty(r)&&this._domains.has(l)&&l>=+n&&+i>l){var u=this._domainType[this.options.subDomain].extractUnit(s),c=this._domains.get(l),m=Math.round((u-l)/a);e===this.RESET_SINGLE_ON_UPDATE?c[m].v=t[r]:isNaN(c[m].v)?c[m].v=t[r]:c[m].v+=t[r]}}},parseURI:function(t,e,n){"use strict";return t=t.replace(/\{\{t:start\}\}/g,e.getTime()/1e3),t=t.replace(/\{\{t:end\}\}/g,n.getTime()/1e3),t=t.replace(/\{\{d:start\}\}/g,e.toISOString()),t=t.replace(/\{\{d:end\}\}/g,n.toISOString())},interpretCSV:function(t){"use strict";var e,n,i={},o=Object.keys(t[0]);for(e=0,n=t.length;n>e;e++)i[t[e][o[0]]]=+t[e][o[1]];return i},resize:function(){"use strict";var t=this,e=t.options,n=e.displayLegend?t.Legend.getDim("width")+e.legendMargin[1]+e.legendMargin[3]:0,i=e.displayLegend?t.Legend.getDim("height")+e.legendMargin[0]+e.legendMargin[2]:0,o=t.graphDim.width-e.domainGutter-e.cellPadding,a=t.graphDim.height-e.domainGutter-e.cellPadding;this.root.transition().duration(e.animationDuration).attr("width",function(){return"middle"===e.legendVerticalPosition||"center"===e.legendVerticalPosition?o+n:Math.max(o,n)}).attr("height",function(){return"middle"===e.legendVerticalPosition||"center"===e.legendVerticalPosition?Math.max(a,i):a+i}),this.root.select(".graph").transition().duration(e.animationDuration).attr("y",function(){return"top"===e.legendVerticalPosition?i:0}).attr("x",function(){return"middle"!==e.legendVerticalPosition&&"center"!==e.legendVerticalPosition||"left"!==e.legendHorizontalPosition?0:n})},next:function(t){"use strict";return 0===arguments.length&&(t=1),this.loadNextDomain(t)},previous:function(t){"use strict";return 0===arguments.length&&(t=1),this.loadPreviousDomain(t)},jumpTo:function(t,e){"use strict";2>arguments.length&&(e=!1);var n=this.getDomainKeys(),i=n[0],o=n[n.length-1];return i>t?this.loadPreviousDomain(this.getDomain(i,t).length):e?this.loadNextDomain(this.getDomain(i,t).length):t>o?this.loadNextDomain(this.getDomain(o,t).length):!1},update:function(t,e,n){"use strict";2>arguments.length&&(e=!0),3>arguments.length&&(n=this.RESET_ALL_ON_UPDATE);var i=this.getDomainKeys(),o=this;this.getDatas(t,new Date(i[0]),this.getSubDomain(i[i.length-1]).pop(),function(){o.fill()},e,n)},setLegend:function(){"use strict";var t=this.options.legend.slice(0);arguments.length>=1&&Array.isArray(arguments[0])&&(this.options.legend=arguments[0]),arguments.length>=2&&(this.options.legendColors=Array.isArray(arguments[1])&&arguments[1].length>=2?[arguments[1][0],arguments[1][1]]:arguments[1]),(arguments.length>0&&!arrayEquals(t,this.options.legend)||arguments.length>=2)&&(this.Legend.buildColors(),this.fill()),this.Legend.redraw(this.graphDim.width-this.options.domainGutter-this.options.cellPadding)},removeLegend:function(){"use strict";return this.options.displayLegend?(this.options.displayLegend=!1,this.Legend.remove(),!0):!1},showLegend:function(){"use strict";return this.options.displayLegend?!1:(this.options.displayLegend=!0,this.Legend.redraw(this.graphDim.width-this.options.domainGutter-this.options.cellPadding),!0)},highlight:function(t){"use strict";return(this.options.highlight=this.expandDateSetting(t))!==[]?(this.fill(),!0):!1},getSVG:function(){"use strict";for(var t={".graph":{},".graph-rect":{},"rect.highlight":{},"rect.now":{},"text.highlight":{},"text.now":{},".domain-background":{},".graph-label":{},".subdomain-text":{},".qi":{}},e=0,n=this.options.legend.length;n>e;e++)t[".q"+e]={};var i=this.root,o=["stroke","stroke-width","stroke-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-miterlimit","fill","fill-opacity","fill-rule","marker","marker-start","marker-mid","marker-end","alignement-baseline","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","kerning","text-anchor","shape-rendering","text-transform","font-family","font","font-size","font-weight"],a=function(e,n,i){-1!==o.indexOf(n)&&(t[e][n]=i)},r=function(t){return i.select(t)[0][0]};for(var s in t)if(t.hasOwnProperty(s)){var l=r(s);if(null!==l)if("getComputedStyle"in window){var u=getComputedStyle(l,null);if(0!==u.length)for(var c=0;u.length>c;c++)a(s,u.item(c),u.getPropertyValue(u.item(c)));else for(var m in u)u.hasOwnProperty(m)&&a(s,m,u[m])}else if("currentStyle"in l){var h=l.currentStyle;for(var g in h)a(s,g,h[g])}}var d='",d+=(new XMLSerializer).serializeToString(this.root.selectAll("svg")[0][0]),d+=(new XMLSerializer).serializeToString(this.root.selectAll("svg")[0][1]),d+=""}};var DomainPosition=function(){"use strict";this.positions=d3.map()};DomainPosition.prototype.getPosition=function(t){"use strict";return this.positions.get(t)},DomainPosition.prototype.getPositionFromIndex=function(t){"use strict";var e=this.getKeys();return this.positions.get(e[t])},DomainPosition.prototype.getLast=function(){"use strict";var t=this.getKeys();return this.positions.get(t[t.length-1])},DomainPosition.prototype.setPosition=function(t,e){"use strict";this.positions.set(t,e)},DomainPosition.prototype.shiftRightBy=function(t){"use strict";this.positions.forEach(function(e,n){this.set(e,n-t)});var e=this.getKeys();this.positions.remove(e[0])},DomainPosition.prototype.shiftLeftBy=function(t){"use strict";this.positions.forEach(function(e,n){this.set(e,n+t)});var e=this.getKeys();this.positions.remove(e[e.length-1])},DomainPosition.prototype.getKeys=function(){"use strict";return this.positions.keys().sort(function(t,e){return parseInt(t,10)-parseInt(e,10)})};var Legend=function(t){"use strict";this.calendar=t,this.computeDim(),null!==t.options.legendColors&&this.buildColors()};Legend.prototype.computeDim=function(){"use strict";var t=this.calendar.options;this.dim={width:t.legendCellSize*(t.legend.length+1)+t.legendCellPadding*t.legend.length,height:t.legendCellSize}},Legend.prototype.remove=function(){"use strict";this.calendar.root.select(".graph-legend").remove(),this.calendar.resize()},Legend.prototype.redraw=function(t){"use strict";function e(t){t.attr("width",l.legendCellSize).attr("height",l.legendCellSize).attr("x",function(t,e){return e*(l.legendCellSize+l.legendCellPadding)})}function n(){switch(l.legendHorizontalPosition){case"right":return"center"===l.legendVerticalPosition||"middle"===l.legendVerticalPosition?t+l.legendMargin[3]:t-a.getDim("width")-l.legendMargin[1];case"middle":case"center":return Math.round(t/2-a.getDim("width")/2);default:return l.legendMargin[3]}}function i(){switch(l.legendVerticalPosition){case"center":case"middle":case"top":return l.legendMargin[0];case"bottom":return r.graphDim.height+l.legendMargin[0]-l.domainGutter-l.cellPadding}}if(!this.calendar.options.displayLegend)return!1;var o,a=this,r=this.calendar,s=r.root,l=r.options;this.computeDim();var u=l.legend.slice(0);u.push(u[u.length-1]+1);var c=r.root.select(".graph-legend");null!==c[0][0]?(s=c,o=s.select("g").selectAll("rect").data(u)):(s="top"===l.legendVerticalPosition?s.insert("svg",".graph"):s.append("svg"),s.attr("x",n()).attr("y",i()),o=s.attr("class","graph-legend").attr("height",a.getDim("height")).attr("width",a.getDim("width")).append("g").selectAll().data(u)),o.enter().append("rect").call(e).attr("class",function(t){return r.Legend.getClass(t,null===r.legendScale)}).attr("fill-opacity",0).call(function(t){null!==r.legendScale&&null!==l.legendColors&&l.legendColors.hasOwnProperty("base")&&t.attr("fill",l.legendColors.base)}).append("title"),o.exit().transition().duration(l.animationDuration).attr("fill-opacity",0).remove(),o.transition().delay(function(t,e){return l.animationDuration*e/10}).call(e).attr("fill-opacity",1).call(function(t){t.attr("fill",function(t,e){return null===r.legendScale?"":0===e?r.legendScale(t-1):r.legendScale(l.legend[e-1])}),t.attr("class",function(t){return r.Legend.getClass(t,null===r.legendScale)})}),o.select("title").text(function(t,e){return 0===e?l.legendTitleFormat.lower.format({min:l.legend[e],name:l.itemName[1]}):e===u.length-1?l.legendTitleFormat.upper.format({max:l.legend[e-1],name:l.itemName[1]}):l.legendTitleFormat.inner.format({down:l.legend[e-1],up:l.legend[e],name:l.itemName[1]})}),s.transition().duration(l.animationDuration).attr("x",n()).attr("y",i()).attr("width",a.getDim("width")).attr("height",a.getDim("height")),s.select("g").transition().duration(l.animationDuration).attr("transform",function(){return"vertical"===l.legendOrientation?"rotate(90 "+l.legendCellSize/2+" "+l.legendCellSize/2+")":""}),r.resize()},Legend.prototype.getDim=function(t){"use strict";switch(t){case"width":return this.dim["horizontal"===this.calendar.options.legendOrientation?"width":"height"];case"height":return this.dim["horizontal"===this.calendar.options.legendOrientation?"height":"width"]}},Legend.prototype.buildColors=function(){"use strict";var t=this.calendar.options;if(null===t.legendColors)return this.calendar.legendScale=null,!1;var e=[];if(Array.isArray(t.legendColors))e=t.legendColors;else{if(!t.legendColors.hasOwnProperty("min")||!t.legendColors.hasOwnProperty("max"))return t.legendColors=null,!1;e=[t.legendColors.min,t.legendColors.max]}var n=t.legend.slice(0);n[0]>0?n.unshift(0):0>n[0]&&n.unshift(n[0]-(n[n.length-1]-n[0])/n.length);var i=d3.scale.linear().range(e).interpolate(d3.interpolateHcl).domain([d3.min(n),d3.max(n)]),o=n.map(function(t){return i(t)});return this.calendar.legendScale=d3.scale.threshold().domain(t.legend).range(o),!0},Legend.prototype.getClass=function(t,e){"use strict";if(null===t||isNaN(t))return"";for(var n=[this.calendar.options.legend.length+1],i=0,o=this.calendar.options.legend.length-1;o>=i;i++){if(this.calendar.options.legend[0]>0&&0>t){n=["1","i"];break}if(this.calendar.options.legend[i]>=t){n=[i+1];break}}return 0===t&&n.push(0),n.unshift(""),(n.join(" r")+(e?n.join(" q"):"")).trim()},String.prototype.format=function(){"use strict";var t=this;for(var e in arguments[0])if(arguments[0].hasOwnProperty(e)){var n=RegExp("\\{"+e+"\\}","gi");t=t.replace(n,arguments[0][e])}return t},"function"==typeof define&&define.amd&&define(["d3"],function(){"use strict";return CalHeatMap}); //@ sourceMappingURL=cal-heatmap.source-map.js \ No newline at end of file diff --git a/cal-heatmap.source-map.js b/cal-heatmap.source-map.js index eec07597..65c9562e 100644 --- a/cal-heatmap.source-map.js +++ b/cal-heatmap.source-map.js @@ -1 +1 @@ -{"version":3,"file":"cal-heatmap.min.js","sources":["cal-heatmap.js"],"names":["mergeRecursive","obj1","obj2","p","constructor","Object","e","arrayEquals","array_a","array_b","length","i","Array","CalHeatMap","_init","self","getDomain","options","start","map","d","getTime","_domains","set","getSubDomain","t","_domainType","subDomain","extractUnit","v","root","d3","select","itemSelector","append","attr","tooltip","Legend","paintOnLoad","verticalDomainLabel","label","position","domainVerticalLabelHeight","height","Math","max","cellSize","domainHorizontalLabelWidth","domainLabelFormat","width","domainMargin","paint","nextSelector","on","itemNamespace","event","preventDefault","loadNextDomain","previousSelector","loadPreviousDomain","displayLegend","redraw","graphDim","domainGutter","cellPadding","afterLoad","loadOnInit","domains","getDomainKeys","getDatas","data","Date","pop","fill","onComplete","w","outer","column","h","row","this","allowedDataType","range","cellRadius","domain","colLimit","rowLimit","weekStartOnMonday","minDate","maxDate","dataType","considerMissingDataAsZero","verticalOrientation","domainDynamicDimension","align","offset","x","y","rotate","legend","legendCellSize","legendCellPadding","legendMargin","legendVerticalPosition","legendHorizontalPosition","legendOrientation","legendColors","highlight","itemName","subDomainTitleFormat","empty","filled","subDomainDateFormat","subDomainTextFormat","legendTitleFormat","lower","inner","upper","animationDuration","onClick","afterLoadNextDomain","afterLoadPreviousDomain","afterLoadData","onMaxDomainReached","onMinDomainReached","min","name","level","ceil","floor","getMinutes","format","date","connector","dt","getFullYear","getMonth","getDate","getHours","hour","total","getDayCountInMonth","getEndOfMonth","getWeekDay","day","getDayCountInYear","dayCountInMonth","getWeekNumber","dayNumber","getDayOfYear","week","weekNumberInMonth","getMonthWeekNumber","weekDay","getDay","setDate","month","year","type","x_day","lastInsertedSvg","_completed","legendDim","NAVIGATE_LEFT","NAVIGATE_RIGHT","RESET_ALL_ON_UPDATE","RESET_SINGLE_ON_UPDATE","APPEND_ON_UPDATE","DEFAULT_LEGEND_MARGIN","_maxDomainReached","_minDomainReached","domainPosition","DomainPosition","legendScale","navigationDir","getDomainPosition","domainIndex","axis","domainDim","tmp","setPosition","enteringDomainDim","exitingDomainDim","getPositionFromIndex","shiftRightBy","getLast","shiftLeftBy","domainRotate","selection","s","domainSvg","selectAll","reverse","svg","enter","classname","subDomainSvgGroup","rect","get","getHighlightClassName","positionSubDomainX","positionSubDomainY","call","hasOwnProperty","base","domainNode","parentNode","html","getSubDomainTitle","offsetWidth","parseInt","getAttribute","offsetHeight","text","formatDate","transition","duration","getPosition","tempWidth","tempHeight","exit","remove","resize","addStyle","element","overflow","arguments","htmlClass","getClass","init","settings","validateSelector","selector","Element","substring","console","log","indexOf","isArray","splice","k","push","prototype","triggerEvent","eventName","successArgs","skip","apply","itemNb","response","parent","shift","reached","formatNumber","f","time","value","count","n","newDomains","getNextDomain","maxDomainIsReached","slice","forEach","key","minDomainIsReached","datetimestamp","keys","sort","a","b","index","dateIsEqual","isNow","date_a","date_b","monthFirstWeekNumber","getWeekNumberInYear","jumpDate","step","setHours","setMonth","setFullYear","getMinuteDomain","stop","minutes","getHourDomain","hours","getDayDomain","days","getWeekDomain","weekStart","endDate","mondays","sundays","getMonthDomain","months","getYearDomain","years","computeDaySubDomainSize","computeMinSubDomainSize","computeHourSubDomainSize","computeWeekSubDomainSize","endOfMonth","endWeekNb","startWeekNb","getPreviousDomain","source","startDate","callback","updateMode","_callback","parseDatas","json","parseURI","csv","tsv","toString","array","domainKeys","subDomainStep","isNaN","domainUnit","has","subDomainUnit","subDomainsData","round","str","replace","toISOString","legendWidth","getDim","legendHeight","graphWidth","graphHeight","next","previous","jumpTo","reset","firstDomain","lastDomain","update","dataSource","setLegend","oldLegend","buildColors","removeLegend","showLegend","getSVG","styles",".graph",".graph-rect","rect.highlight","rect.now","text.highlight","text.now",".domain-background",".graph-label",".subdomain-text",".qi","j","whitelistStyles","filterStyles","attribute","property","getElement","dom","window","cs","getComputedStyle","item","getPropertyValue","css","currentStyle","string","style","l","XMLSerializer","serializeToString","positions","getKeys","dim","calendar","computeDim","legendCellLayout","getLegendXPosition","getLegendYPosition","legendItem","_legend","legendElement","insert","delay","down","up","_colorRange","unshift","colorScale","scale","linear","interpolate","interpolateHcl","threshold","withCssClass","join","trim","String","formatted","prop","regexp","RegExp","define","amd"],"mappings":"AA4yFA,QAASA,gBAAeC,EAAMC,GAE7B,IAAK,GAAIC,KAAKD,GACb,IAGED,EAAKE,GADFD,EAAKC,GAAGC,cAAgBC,OACjBL,eAAeC,EAAKE,GAAID,EAAKC,IAE7BD,EAAKC,GAEf,MAAMG,GAEPL,EAAKE,GAAKD,EAAKC,GAIjB,MAAOF,GAUR,QAASM,aAAYC,EAASC,GAE1B,IAAKA,IAAYD,EACb,OAAO,CAIX,IAAIA,EAAQE,SAAWD,EAAQC,OAC3B,OAAO,CAGX,KAAK,GAAIC,GAAI,EAAOH,EAAQE,OAAZC,EAAoBA,IAEhC,GAAIH,EAAQG,YAAcC,QAASH,EAAQE,YAAcC,QAErD,IAAKL,YAAYC,EAAQG,GAAIF,EAAQE,IACjC,OAAO,MAGV,IAAIH,EAAQG,KAAOF,EAAQE,GAE5B,OAAO,CAGf,QAAO,EAt1FX,GAAIE,YAA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SAAS7W,QAAQkF,OAAOxF,IAAlCuP,EAAsC,CACzCa,GAASpQ,EAAE,EACX,QASF,MALU,KAANuP,GACHa,EAAM9B,KAAK,GAGZ8B,EAAM4H,QAAQ,KACN5H,EAAMoI,KAAK,OAASD,EAAenI,EAAMoI,KAAK,MAAO,KAAKC,QAQnEC,OAAOnK,UAAU/G,OAAS,WACzB,GAAImR,GAAYtU,IAChB,KAAK,GAAIuU,KAAQrL,WAAU,GAAI,CAC9B,GAAIsL,GAAaC,OAAO,MAAQF,EAAO,MAAO,KAC9CD,GAAYA,EAAU9E,QAAQgF,EAAQtL,UAAU,GAAGqL,IAEpD,MAAOD,IA8Dc,kBAAXI,SAAyBA,OAAOC,KAC1CD,QAAQ,MAAO,WACd,MAAO7Y"} \ No newline at end of file +{"version":3,"file":"cal-heatmap.min.js","sources":["cal-heatmap.js"],"names":["mergeRecursive","obj1","obj2","p","constructor","Object","e","arrayEquals","arrayA","arrayB","length","i","Array","CalHeatMap","_initCalendar","self","verticalDomainLabel","options","label","position","domainVerticalLabelHeight","height","Math","max","cellSize","domainHorizontalLabelWidth","domainLabelFormat","width","paint","nextSelector","d3","select","on","itemNamespace","event","preventDefault","loadNextDomain","previousSelector","loadPreviousDomain","Legend","redraw","graphDim","domainGutter","cellPadding","afterLoad","domains","getDomainKeys","loadOnInit","getDatas","data","Date","getSubDomain","pop","fill","onComplete","checkIfMinDomainIsReached","checkIfMaxDomainIsReached","getNextDomain","getTime","w","d","outer","_domainType","subDomain","column","arguments","domainMargin","h","row","this","allowedDataType","itemSelector","paintOnLoad","range","cellRadius","domain","colLimit","rowLimit","weekStartOnMonday","start","minDate","maxDate","dataType","considerMissingDataAsZero","verticalOrientation","domainDynamicDimension","align","offset","x","y","rotate","legend","displayLegend","legendCellSize","legendCellPadding","legendMargin","legendVerticalPosition","legendHorizontalPosition","legendOrientation","legendColors","highlight","itemName","subDomainTitleFormat","empty","filled","subDomainDateFormat","subDomainTextFormat","legendTitleFormat","lower","inner","upper","animationDuration","tooltip","onClick","afterLoadNextDomain","afterLoadPreviousDomain","afterLoadData","onMaxDomainReached","onMinDomainReached","min","name","level","ceil","floor","getMinutes","format","date","connector","extractUnit","getFullYear","getMonth","getDate","getHours","hour","total","getDayCountInMonth","getEndOfMonth","getWeekDay","day","getDayCountInYear","dayCountInMonth","getWeekNumber","dayNumber","getDayOfYear","week","weekNumberInMonth","getMonthWeekNumber","dt","weekDay","getDay","setDate","month","year","type","hasOwnProperty","x_day","lastInsertedSvg","_completed","_domains","map","legendDim","NAVIGATE_LEFT","NAVIGATE_RIGHT","RESET_ALL_ON_UPDATE","RESET_SINGLE_ON_UPDATE","APPEND_ON_UPDATE","DEFAULT_LEGEND_MARGIN","root","_maxDomainReached","_minDomainReached","domainPosition","DomainPosition","legendScale","_init","getDomain","set","t","v","append","attr","navigationDir","getDomainPosition","domainIndex","axis","domainDim","tmp","setPosition","enteringDomainDim","exitingDomainDim","getPositionFromIndex","shiftRightBy","getLast","shiftLeftBy","domainRotate","selection","s","domainSvg","selectAll","reverse","svg","enter","classname","subDomainSvgGroup","rect","get","getHighlightClassName","positionSubDomainX","positionSubDomainY","call","base","domainNode","parentNode","html","getSubDomainTitle","offsetWidth","parseInt","getAttribute","offsetHeight","text","formatDate","transition","duration","getPosition","tempWidth","tempHeight","exit","remove","resize","prototype","init","settings","validateSelector","selector","canBeFalse","Element","Error","getOptimalSubDomain","validateDomainType","parent","substring","autoAlignLabel","autoAddLegendMargin","expandMarginSetting","value","isArray","console","log","slice","expandItemName","parseColLimit","parseRowLimit","indexOf","error","message","k","expandDateSetting","filter","addStyle","element","overflow","htmlClass","getClass","triggerEvent","eventName","successArgs","skip","apply","itemNb","response","shift","reached","upperBound","minDomainIsReached","maxDomainIsReached","lowerBound","formatNumber","f","time","count","n","bound","loadNewDomains","end","direction","newDomains","buildSubDomain","backward","datetimestamp","keys","sort","a","b","index","dateIsEqual","isNow","dateA","dateB","monthFirstWeekNumber","getWeekNumberInYear","jumpDate","step","setHours","setMonth","setFullYear","getMinuteDomain","stop","minutes","getHourDomain","hours","getDayDomain","days","getWeekDomain","weekStart","endDate","mondays","sundays","getMonthDomain","months","getYearDomain","years","computeDaySubDomainSize","computeMinSubDomainSize","computeHourSubDomainSize","computeWeekSubDomainSize","endOfMonth","endWeekNb","startWeekNb","getPreviousDomain","source","startDate","callback","updateMode","_callback","interpretCSV","parseDatas","json","parseURI","csv","tsv","toString","forEach","key","array","domainKeys","subDomainStep","domainUnit","isNaN","has","subDomainUnit","subDomainsData","round","str","replace","toISOString","legendWidth","getDim","legendHeight","graphWidth","graphHeight","next","previous","jumpTo","reset","firstDomain","lastDomain","update","dataSource","setLegend","oldLegend","buildColors","removeLegend","showLegend","args","getSVG","styles",".graph",".graph-rect","rect.highlight","rect.now","text.highlight","text.now",".domain-background",".graph-label",".subdomain-text",".qi","j","whitelistStyles","filterStyles","attribute","property","getElement","dom","window","cs","getComputedStyle","item","getPropertyValue","css","currentStyle","string","style","l","XMLSerializer","serializeToString","positions","getKeys","dim","calendar","computeDim","legendCellLayout","getLegendXPosition","getLegendYPosition","legendItem","_legend","push","legendElement","insert","delay","down","up","_colorRange","unshift","colorScale","scale","linear","interpolate","interpolateHcl","threshold","withCssClass","join","trim","String","formatted","prop","regexp","RegExp","define","amd"],"mappings":"AAsoGA,QAASA,gBAAeC,EAAMC,GAC7B,YAGA,KAAK,GAAIC,KAAKD,GACb,IAGED,EAAKE,GADFD,EAAKC,GAAGC,cAAgBC,OACjBL,eAAeC,EAAKE,GAAID,EAAKC,IAE7BD,EAAKC,GAEf,MAAMG,GAEPL,EAAKE,GAAKD,EAAKC,GAIjB,MAAOF,GAUR,QAASM,aAAYC,EAAQC,GAC5B,YAGG,KAAKA,IAAWD,EACZ,OAAO,CAIX,IAAIA,EAAOE,SAAWD,EAAOC,OACzB,OAAO,CAGX,KAAK,GAAIC,GAAI,EAAOH,EAAOE,OAAXC,EAAmBA,IAE/B,GAAIH,EAAOG,YAAcC,QAASH,EAAOE,YAAc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3.5 (Wed Oct 16 2013 23:46:44) +/*! cal-heatmap v3.3.5 (Wed Oct 16 2013 23:56:23) * --------------------------------------------- * Cal-Heatmap is a javascript module to create calendar heatmap to visualize time series data * https://github.com/kamisama/cal-heatmap