summaryrefslogtreecommitdiff
path: root/app/assets/javascripts
diff options
context:
space:
mode:
authorWinnie Hellmann <winnie@gitlab.com>2017-12-11 23:10:20 +0100
committerWinnie Hellmann <winnie@gitlab.com>2017-12-18 11:13:41 +0100
commitb20c63d5a726e6536be7679884bff94927773e6c (patch)
tree9be3fc8ec72d68b64ae69f206e47785899aeab63 /app/assets/javascripts
parent4f73e14f2c30c907d4ead31dd8034aea37f14544 (diff)
downloadgitlab-ce-b20c63d5a726e6536be7679884bff94927773e6c.tar.gz
Translate contributors graph x-axis
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/graphs/stat_graph_contributors_graph.js26
1 files changed, 24 insertions, 2 deletions
diff --git a/app/assets/javascripts/graphs/stat_graph_contributors_graph.js b/app/assets/javascripts/graphs/stat_graph_contributors_graph.js
index f64b4638485..ee25def0fa5 100644
--- a/app/assets/javascripts/graphs/stat_graph_contributors_graph.js
+++ b/app/assets/javascripts/graphs/stat_graph_contributors_graph.js
@@ -1,10 +1,25 @@
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, max-len, no-restricted-syntax, vars-on-top, no-use-before-define, no-param-reassign, new-cap, no-underscore-dangle, wrap-iife, comma-dangle, no-return-assign, prefer-arrow-callback, quotes, prefer-template, newline-per-chained-call, no-else-return, no-shadow */
import _ from 'underscore';
import d3 from 'd3';
+import { createDateTimeFormat } from '../locale';
const extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
const hasProp = {}.hasOwnProperty;
+const dayFormat = createDateTimeFormat({ month: 'short', day: 'numeric' });
+const monthFormat = createDateTimeFormat({ month: 'long' });
+const yearFormat = createDateTimeFormat({ year: 'numeric' });
+
+const xTickFormat = (date) => {
+ if (date.getDate() !== 1) {
+ return dayFormat.format(date);
+ } else if (date.getMonth() > 0) {
+ return monthFormat.format(date);
+ } else {
+ return yearFormat.format(date);
+ }
+};
+
export const ContributorsGraph = (function() {
function ContributorsGraph() {}
@@ -131,7 +146,10 @@ export const ContributorsMasterGraph = (function(superClass) {
};
ContributorsMasterGraph.prototype.create_axes = function() {
- this.x_axis = d3.svg.axis().scale(this.x).orient("bottom");
+ this.x_axis = d3.svg.axis()
+ .scale(this.x)
+ .orient('bottom')
+ .tickFormat(xTickFormat);
return this.y_axis = d3.svg.axis().scale(this.y).orient("left").ticks(5);
};
@@ -219,7 +237,11 @@ export const ContributorsAuthorGraph = (function(superClass) {
};
ContributorsAuthorGraph.prototype.create_axes = function() {
- this.x_axis = d3.svg.axis().scale(this.x).orient("bottom").ticks(8);
+ this.x_axis = d3.svg.axis()
+ .scale(this.x)
+ .orient('bottom')
+ .ticks(8)
+ .tickFormat(xTickFormat);
return this.y_axis = d3.svg.axis().scale(this.y).orient("left").ticks(5);
};