diff options
author | Yusaku Sako <yusaku@apache.org> | 2012-12-09 14:32:16 +0000 |
---|---|---|
committer | Yusaku Sako <yusaku@apache.org> | 2012-12-09 14:32:16 +0000 |
commit | b885ee6ce8140e712ac865b502e8148722b88d37 (patch) | |
tree | 2bebe22207a9cbf32eb505ad995b5c8fe0004d96 /ambari-web | |
parent | 18f6dd5c550d39e8658f8bf16a3edf2e98a2a2d8 (diff) |
AMBARI-1034. Metric Charts - display local time rather than UTC. (Srimanth Gunturi via yusaku)
git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/branches/AMBARI-666@1418975 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'ambari-web')
-rw-r--r-- | ambari-web/app/views/common/chart/linear_time.js | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/ambari-web/app/views/common/chart/linear_time.js b/ambari-web/app/views/common/chart/linear_time.js index d25cf42a97..69cede611f 100644 --- a/ambari-web/app/views/common/chart/linear_time.js +++ b/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]; + } };
\ No newline at end of file |