Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

AMBARI-1034. Metric Charts - display local time rather than UTC. (Sri…

…manth Gunturi via yusaku)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/branches/AMBARI-666@1418975 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit b885ee6ce8140e712ac865b502e8148722b88d37 1 parent 18f6dd5
Yusaku Sako authored
View
3  AMBARI-666-CHANGES.txt
@@ -424,6 +424,9 @@ AMBARI-666 branch (unreleased changes)
IMPROVEMENTS
+ AMBARI-1034. Metric Charts - display local time rather than UTC.
+ (Srimanth Gunturi via yusaku)
+
AMBARI-1033. Nagios and Ganglia links should use public host names in URLs.
(Srimanth Gunturi via yusaku)
View
32 ambari-web/app/views/common/chart/linear_time.js
@@ -253,6 +253,22 @@ App.ChartLinearTimeView = Ember.View.extend({
this._showMessage('info', 'No Data', 'There was no data available.');
}
},
+
+ /**
+ * Returns a custom time unit for the graph's X axis. This is needed
+ * as Rickshaw's default time X axis uses UTC time, which can be confusing
+ * for users expecting locale specific time. This value defaults to
+ * App.ChartLinearTimeView.FifteenMinuteTimeUnit.
+ *
+ * If <code>null</code> is returned, Rickshaw's default time unit is used.
+ *
+ * @type Function
+ * @return Rickshaw.Fixtures.Time
+ * @default App.ChartLinearTimeView.FifteenMinuteTimeUnit
+ */
+ localeTimeUnit: function(){
+ return App.ChartLinearTimeView.FifteenMinuteTimeUnit;
+ },
/**
* @private
@@ -333,7 +349,8 @@ App.ChartLinearTimeView = Ember.View.extend({
_graph.renderer.unstack = false;
xAxis = new Rickshaw.Graph.Axis.Time({
- graph: _graph
+ graph: _graph,
+ timeUnit: this.localeTimeUnit()
});
yAxis = new Rickshaw.Graph.Axis.Y({
@@ -522,4 +539,17 @@ App.ChartLinearTimeView.TimeElapsedFormatter = function (millis) {
}
}
return value;
+};
+
+/**
+ * A time unit which can be used for showing 15 minute intervals on X axis.
+ *
+ * @type Rickshaw.Fixtures.Time
+ */
+App.ChartLinearTimeView.FifteenMinuteTimeUnit = {
+ name: '15 minute',
+ seconds: 60 * 15,
+ formatter: function (d) {
+ return d.toLocaleString().match(/(\d+:\d+):/)[1];
+ }
};
Please sign in to comment.
Something went wrong with that request. Please try again.