Skip to content

Commit

Permalink
Fix graphs to display local time instead of UTC time
Browse files Browse the repository at this point in the history
  • Loading branch information
rjuju committed Oct 3, 2016
1 parent fa01fd9 commit ba29159
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 15 deletions.
11 changes: 1 addition & 10 deletions powa/static/js/powa/views/BarGraphView.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,9 @@ define(["rickshaw", "d3", "powa/views/TimeView"],
renderer: 'bar',
series: series || []
}));
var time = new Rickshaw.Fixtures.Time();
var seconds = time.unit('second');
var self = this;
this.x_axis = new Rickshaw.Graph.Axis.Time({
graph: this.graph,
tickFormat: function(x, index){
var value = self.graph.series[0].data[x - 1.5];
if(value){
return value[self.model.get("x_label_attr")];
}
return "";
}
timeFixture: new Rickshaw.Fixtures.Time.Local()
});
this.adaptGraph(series);
},
Expand Down
2 changes: 1 addition & 1 deletion powa/static/js/powa/views/GraphPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ define(["rickshaw", "d3"], function(rickshaw, d3){
var graph = new Rickshaw.Graph(graphArgs);
new Rickshaw.Graph.Axis.Time({
graph: graph,
tickFormat: parent.x.tickFormat()
timeFixture: new Rickshaw.Fixtures.Time.Local()
});
self.previews.push(graph);

Expand Down
4 changes: 1 addition & 3 deletions powa/static/js/powa/views/LineGraphView.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ define(["rickshaw", "d3", "powa/views/TimeView"],
series: series || [],
interpolation: 'linear'
}));
var time = new Rickshaw.Fixtures.Time();
var seconds = time.unit('second');
this.x_axis = new Rickshaw.Graph.Axis.Time( {
graph: this.graph,
tickFormat: this.graph.x.tickFormat(),
timeFixture: new Rickshaw.Fixtures.Time.Local()
} );
},

Expand Down
3 changes: 2 additions & 1 deletion powa/static/js/powa/views/TimeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ define(["powa/views/GraphView","powa/views/GraphPreview"], function(GraphView, G
var self = this;
var hoverDetail = new Rickshaw.Graph.HoverDetail( {
graph: this.graph,
xFormatter: function(x){ return new moment.unix(x).format("LLLL");},
formatter: function(series, x, y){
var type = series.metric.get("type") || "number";
var formatter = self.axisFormats[type];
var date = '<span class="date">' + new Date(x * 1000).toUTCString() + '</span>';
var date = '<span class="date">' + new moment.unix(x).format("lll") + '</span>';
var swatch = '<span class="detail_swatch" style="background-color: ' + series.color + '"></span>';
var content = swatch + series.label + ": " + formatter(y) + '<br/>' + date;
return content;
Expand Down

0 comments on commit ba29159

Please sign in to comment.