diff options
author | Clement Ho <ClemMakesApps@gmail.com> | 2016-08-11 21:21:13 +0300 |
---|---|---|
committer | Clement Ho <ClemMakesApps@gmail.com> | 2016-09-07 18:26:44 +0300 |
commit | a958a046a8f6d273736f8270990cf13cdb12afab (patch) | |
tree | b6b88d069fb7437c27f01b1e69a79ca885d553a4 /app/assets/javascripts/users | |
parent | f7b64a46161337cf8c2d8a5cb8c154ab9195a00f (diff) |
Fix contributions calendar month label truncation
Diffstat (limited to 'app/assets/javascripts/users')
-rw-r--r-- | app/assets/javascripts/users/calendar.js | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/app/assets/javascripts/users/calendar.js b/app/assets/javascripts/users/calendar.js index 74ecf4f4cf9..90cf551b32e 100644 --- a/app/assets/javascripts/users/calendar.js +++ b/app/assets/javascripts/users/calendar.js @@ -52,8 +52,22 @@ this.initTooltips(); } + // Add extra padding for the last month label if it is also the last column + Calendar.prototype.getExtraWidthPadding = function(group) { + var extraWidthPadding = 0; + var lastColMonth = this.timestampsTmp[group - 1][0].date.getMonth(); + var secondLastColMonth = this.timestampsTmp[group - 2][0].date.getMonth(); + + if (lastColMonth != secondLastColMonth) { + extraWidthPadding = 3; + } + + return extraWidthPadding; + } + Calendar.prototype.renderSvg = function(group) { - return this.svg = d3.select('.js-contrib-calendar').append('svg').attr('width', (group + 1) * this.daySizeWithSpace).attr('height', 167).attr('class', 'contrib-calendar'); + var width = (group + 1) * this.daySizeWithSpace + this.getExtraWidthPadding(group); + return this.svg = d3.select('.js-contrib-calendar').append('svg').attr('width', width).attr('height', 167).attr('class', 'contrib-calendar'); }; Calendar.prototype.renderDays = function() { |