src/cal-heatmap.js
function() {
		"use strict";

		var parent = this;
		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 - options.domainGutter - options.cellPadding;
		var graphHeight = parent.graphDim.height - options.domainGutter - options.cellPadding;

		this.root.transition().duration(options.animationDuration)
			.attr("width", function() {
				if (options.legendVerticalPosition === "middle" || options.legendVerticalPosition === "center") {
					return graphWidth + legendWidth;
				}
				return Math.max(graphWidth, legendWidth);
			})
			.attr("height", function() {
				if (options.legendVerticalPosition === "middle" || options.legendVerticalPosition === "center") {
					return Math.max(graphHeight, legendHeight);
				}
				return graphHeight + legendHeight;
			})
		;

		this.root.select(".graph").transition().duration(options.animationDuration)
			.attr("y", function() {
				if (options.legendVerticalPosition === "top") {
					return legendHeight;
				}
				return 0;
			})
			.attr("x", function() {
				if (
					(options.legendVerticalPosition === "middle" || options.legendVerticalPosition === "center") &&
					options.legendHorizontalPosition === "left") {
					return legendWidth;
				}
				return 0;

			})
		;
	}
function() {
		"use strict";

		var parent = this;
		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 - options.domainGutter - options.cellPadding;
		var graphHeight = parent.graphDim.height - options.domainGutter - options.cellPadding;

		this.root.transition().duration(options.animationDuration)
			.attr("width", function() {
				if (options.legendVerticalPosition === "middle" || options.legendVerticalPosition === "center") {
					return graphWidth + legendWidth;
				}
				return Math.max(graphWidth, legendWidth);
			})
			.attr("height", function() {
				if (options.legendVerticalPosition === "middle" || options.legendVerticalPosition === "center") {
					return Math.max(graphHeight, legendHeight);
				}
				return graphHeight + legendHeight;
			})
		;

		this.root.select(".graph").transition().duration(options.animationDuration)
			.attr("y", function() {
				if (options.legendVerticalPosition === "top") {
					return legendHeight;
				}
				return 0;
			})
			.attr("x", function() {
				if (
					(options.legendVerticalPosition === "middle" || options.legendVerticalPosition === "center") &&
					options.legendHorizontalPosition === "left") {
					return legendWidth;
				}
				return 0;

			})
		;
	}
function ( ) { "use strict" ; var parent = this ; 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 - options . domainGutter - options . cellPadding ; var graphHeight = parent . graphDim . height - options . domainGutter - options . cellPadding ; this . root . transition ( ) . duration ( options . animationDuration ) . attr ( "width" , function ( ) { if ( options . legendVerticalPosition === "middle" || options . legendVerticalPosition === "center" ) { return graphWidth + legendWidth ; } return Math . max ( graphWidth , legendWidth ) ; } ) . attr ( "height" , function ( ) { if ( options . legendVerticalPosition === "middle" || options . legendVerticalPosition === "center" ) { return Math . max ( graphHeight , legendHeight ) ; } return graphHeight + legendHeight ; } ) ; this . root . select ( ".graph" ) . transition ( ) . duration ( options . animationDuration ) . attr ( "y" , function ( ) { if ( options . legendVerticalPosition === "top" ) { return legendHeight ; } return 0 ; } ) . attr ( "x" , function ( ) { if ( ( options . legendVerticalPosition === "middle" || options . legendVerticalPosition === "center" ) && options . legendHorizontalPosition === "left" ) { return legendWidth ; } return 0 ; } ) ; }
Handle the calendar layout and dimension

Expand and shrink the container depending on its children dimension
Also rearrange the children position depending on their dimension,
and the legend position

@return void
Handle the calendar layout and dimension