This commit is contained in:
Joseph Schorr 2013-11-27 16:56:07 -05:00
parent cca5daf097
commit 6c1d2afc0f
5 changed files with 19 additions and 21 deletions

View file

@ -1269,8 +1269,7 @@ RepositoryUsageChart.prototype.draw = function(container) {
/**
* A chart which displays the last seven days of actions in the account.
*/
function LogUsageChart(logData, titleMap) {
this.logs_ = logData;
function LogUsageChart(titleMap) {
this.titleMap_ = titleMap;
this.colorScale_ = d3.scale.category20();
}
@ -1279,15 +1278,15 @@ function LogUsageChart(logData, titleMap) {
/**
* Builds the D3-representation of the data.
*/
LogUsageChart.prototype.buildData_ = function() {
LogUsageChart.prototype.buildData_ = function(logs) {
var parseDate = d3.time.format("%a, %d %b %Y %H:%M:%S GMT").parse
// Build entries for each kind of event that occurred, on each day. We have one
// entry per {kind, day} pair.
var map = {};
var entries = [];
for (var i = 0; i < this.logs_.length; ++i) {
var log = this.logs_[i];
for (var i = 0; i < logs.length; ++i) {
var log = logs[i];
var title = this.titleMap_[log.kind] || log.kind;
var datetime = parseDate(log.datetime);
var formatted = (datetime.getMonth() + 1) + '/' + datetime.getDate();
@ -1424,7 +1423,10 @@ LogUsageChart.prototype.handleStateChange_ = function(e) {
/**
* Draws the chart in the given container element.
*/
LogUsageChart.prototype.draw = function(container) {
LogUsageChart.prototype.draw = function(container, logData) {
// Reset the container's contents.
document.getElementById(container).innerHTML = '<svg></svg>';
// Returns a date offset from the given date by "days" Days.
var offsetDate = function(d, days) {
var copy = new Date(d.getTime());
@ -1433,7 +1435,7 @@ LogUsageChart.prototype.draw = function(container) {
};
var that = this;
var data = this.buildData_();
var data = this.buildData_(logData);
nv.addGraph(function() {
// Build the chart itself.
var chart = nv.models.multiBarChart()