|
1 | | -/*! cal-heatmap v3.1.0 (Thu Aug 08 2013 01:26:26) |
| 1 | +/*! cal-heatmap v3.1.1 (Wed Sep 04 2013 15:37:25) |
2 | 2 | * --------------------------------------------- |
3 | 3 | * Cal-Heatmap is a javascript module to create calendar heatmap to visualize time series data, a la github contribution graph |
4 | 4 | * https://github.com/kamisama/cal-heatmap |
@@ -100,7 +100,11 @@ var CalHeatMap = function() { |
100 | 100 |
|
101 | 101 | rotate: null, |
102 | 102 |
|
103 | | - width: 100 |
| 103 | + // Used only on vertical orientation |
| 104 | + width: 100, |
| 105 | + |
| 106 | + // Used only on horizontal orientation |
| 107 | + height: null |
104 | 108 | }, |
105 | 109 |
|
106 | 110 | // ================================================ |
@@ -483,9 +487,13 @@ var CalHeatMap = function() { |
483 | 487 |
|
484 | 488 | self.verticalDomainLabel = (self.options.label.position === "top" || self.options.label.position === "bottom"); |
485 | 489 |
|
486 | | - self.domainVerticalLabelHeight = Math.max(25, self.options.cellSize*2); |
| 490 | + self.domainVerticalLabelHeight = self.options.label.height === null ? Math.max(25, self.options.cellSize*2) : self.options.label.height; |
487 | 491 | self.domainHorizontalLabelWidth = 0; |
488 | 492 |
|
| 493 | + if (self.options.domainLabelFormat === "" && self.options.label.height === null) { |
| 494 | + self.domainVerticalLabelHeight = 0; |
| 495 | + } |
| 496 | + |
489 | 497 | if (!self.verticalDomainLabel) { |
490 | 498 | self.domainVerticalLabelHeight = 0; |
491 | 499 | self.domainHorizontalLabelWidth = self.options.label.width; |
@@ -730,50 +738,52 @@ var CalHeatMap = function() { |
730 | 738 | // =========================================================================// |
731 | 739 | // PAINTING LABEL // |
732 | 740 | // =========================================================================// |
733 | | - self.svg.append("text") |
734 | | - .attr("class", "graph-label") |
735 | | - .attr("y", function(d) { |
736 | | - var y = self.options.domainMargin[0]; |
737 | | - switch(self.options.label.position) { |
738 | | - case "top" : y += self.domainVerticalLabelHeight/2; break; |
739 | | - case "bottom" : y += h(d) + self.domainVerticalLabelHeight/2; |
740 | | - } |
| 741 | + if (self.options.domainLabelFormat !== "") { |
| 742 | + self.svg.append("text") |
| 743 | + .attr("class", "graph-label") |
| 744 | + .attr("y", function(d) { |
| 745 | + var y = self.options.domainMargin[0]; |
| 746 | + switch(self.options.label.position) { |
| 747 | + case "top" : y += self.domainVerticalLabelHeight/2; break; |
| 748 | + case "bottom" : y += h(d) + self.domainVerticalLabelHeight/2; |
| 749 | + } |
741 | 750 |
|
742 | | - return y + self.options.label.offset.y * |
743 | | - ( |
744 | | - ((self.options.label.rotate === "right" && self.options.label.position === "right") || |
745 | | - (self.options.label.rotate === "left" && self.options.label.position === "left")) ? |
746 | | - -1 : 1 |
747 | | - ); |
748 | | - }) |
749 | | - .attr("x", function(d){ |
750 | | - var x = self.options.domainMargin[3]; |
751 | | - switch(self.options.label.position) { |
752 | | - case "right" : x += w(d); break; |
753 | | - case "bottom" : |
754 | | - case "top" : x += w(d)/2; |
755 | | - } |
| 751 | + return y + self.options.label.offset.y * |
| 752 | + ( |
| 753 | + ((self.options.label.rotate === "right" && self.options.label.position === "right") || |
| 754 | + (self.options.label.rotate === "left" && self.options.label.position === "left")) ? |
| 755 | + -1 : 1 |
| 756 | + ); |
| 757 | + }) |
| 758 | + .attr("x", function(d){ |
| 759 | + var x = self.options.domainMargin[3]; |
| 760 | + switch(self.options.label.position) { |
| 761 | + case "right" : x += w(d); break; |
| 762 | + case "bottom" : |
| 763 | + case "top" : x += w(d)/2; |
| 764 | + } |
756 | 765 |
|
757 | | - if (self.options.label.align === "right") { |
758 | | - return x + self.domainHorizontalLabelWidth - self.options.label.offset.x * |
759 | | - (self.options.label.rotate === "right" ? -1 : 1); |
760 | | - } |
761 | | - return x + self.options.label.offset.x; |
| 766 | + if (self.options.label.align === "right") { |
| 767 | + return x + self.domainHorizontalLabelWidth - self.options.label.offset.x * |
| 768 | + (self.options.label.rotate === "right" ? -1 : 1); |
| 769 | + } |
| 770 | + return x + self.options.label.offset.x; |
762 | 771 |
|
763 | | - }) |
764 | | - .attr("text-anchor", function() { |
765 | | - switch(self.options.label.align) { |
766 | | - case "start" : |
767 | | - case "left" : return "start"; |
768 | | - case "end" : |
769 | | - case "right" : return "end"; |
770 | | - default : return "middle"; |
771 | | - } |
772 | | - }) |
773 | | - .attr("dominant-baseline", function() { return self.verticalDomainLabel ? "middle" : "top"; }) |
774 | | - .text(function(d) { return self.formatDate(new Date(d), self.options.domainLabelFormat); }) |
775 | | - .call(domainRotate) |
776 | | - ; |
| 772 | + }) |
| 773 | + .attr("text-anchor", function() { |
| 774 | + switch(self.options.label.align) { |
| 775 | + case "start" : |
| 776 | + case "left" : return "start"; |
| 777 | + case "end" : |
| 778 | + case "right" : return "end"; |
| 779 | + default : return "middle"; |
| 780 | + } |
| 781 | + }) |
| 782 | + .attr("dominant-baseline", function() { return self.verticalDomainLabel ? "middle" : "top"; }) |
| 783 | + .text(function(d) { return self.formatDate(new Date(d), self.options.domainLabelFormat); }) |
| 784 | + .call(domainRotate) |
| 785 | + ; |
| 786 | + } |
777 | 787 |
|
778 | 788 | function domainRotate(selection) { |
779 | 789 | switch (self.options.label.rotate) { |
@@ -804,9 +814,6 @@ var CalHeatMap = function() { |
804 | 814 | } |
805 | 815 | } |
806 | 816 |
|
807 | | - |
808 | | - |
809 | | - |
810 | 817 | // =========================================================================// |
811 | 818 | // PAINTING DOMAIN SUBDOMAIN CONTENT // |
812 | 819 | // =========================================================================// |
|
0 commit comments