mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Fixed x axis moving around *hopefully*
This commit is contained in:
@@ -1,3 +1,27 @@
|
||||
function date_by_subtracting_days(date, days) {
|
||||
return new Date(
|
||||
date.getFullYear(),
|
||||
date.getMonth(),
|
||||
date.getDate() - days,
|
||||
date.getHours(),
|
||||
date.getMinutes(),
|
||||
date.getSeconds(),
|
||||
date.getMilliseconds()
|
||||
);
|
||||
}
|
||||
|
||||
function date_by_adding_hours(date, hours) {
|
||||
return new Date(
|
||||
date.getFullYear(),
|
||||
date.getMonth(),
|
||||
date.getDate(),
|
||||
date.getHours() + hours,
|
||||
date.getMinutes(),
|
||||
date.getSeconds(),
|
||||
date.getMilliseconds()
|
||||
);
|
||||
}
|
||||
|
||||
function get_utc_time() {
|
||||
var date = new Date()
|
||||
return new Date(
|
||||
@@ -10,17 +34,10 @@ function get_utc_time() {
|
||||
)
|
||||
}
|
||||
|
||||
function date_by_subtracting_days(date, days) {
|
||||
return new Date(
|
||||
date.getFullYear(),
|
||||
date.getMonth(),
|
||||
date.getDate() - days,
|
||||
date.getHours(),
|
||||
date.getMinutes(),
|
||||
date.getSeconds(),
|
||||
date.getMilliseconds()
|
||||
);
|
||||
function refresh() {
|
||||
window.location.reload(true);
|
||||
}
|
||||
setTimeout(refresh, 900000); //15 minutes = 900000 ms
|
||||
|
||||
function create_chart( inp_data, name, time, title ) {
|
||||
require( ["d3"], function (e) {
|
||||
@@ -62,41 +79,6 @@ function create_chart( inp_data, name, time, title ) {
|
||||
}
|
||||
var chart_width = width + margin.left + margin.right;
|
||||
|
||||
var y = d3.scale.linear()
|
||||
.range([height, 0]);
|
||||
|
||||
var yAxis = d3.svg.axis()
|
||||
.scale(y)
|
||||
.orient("left")
|
||||
.tickFormat( function(d) { return d3.round( d*d3.max(data), 0 ) });
|
||||
|
||||
|
||||
if (time == "hours") {
|
||||
var x = d3.time.scale()
|
||||
.domain([get_utc_time(), date_by_subtracting_days(get_utc_time(), 1)])
|
||||
.rangeRound([0, width]);
|
||||
|
||||
var xAxis = d3.svg.axis()
|
||||
.scale(x)
|
||||
.tickFormat(d3.time.format('%b %d %H'))
|
||||
.ticks(d3.time.hours, 1)
|
||||
.orient("bottom")
|
||||
.tickSize(0)
|
||||
.tickPadding(8);
|
||||
} else if (time == "days") {
|
||||
var x = d3.time.scale()
|
||||
.domain([get_utc_time(), date_by_subtracting_days(get_utc_time(), 30)])
|
||||
.rangeRound([0, width]);
|
||||
|
||||
var xAxis = d3.svg.axis()
|
||||
.scale(x)
|
||||
.tickFormat(d3.time.format('%b %d'))
|
||||
.ticks(d3.time.days, 1)
|
||||
.orient("bottom")
|
||||
.tickSize(0)
|
||||
.tickPadding(8);
|
||||
}
|
||||
|
||||
var chart = d3.select("#" + name)
|
||||
.attr("width", chart_width)
|
||||
.attr("height", chart_width)
|
||||
@@ -152,24 +134,50 @@ function create_chart( inp_data, name, time, title ) {
|
||||
chart.append("g")
|
||||
.append("text")
|
||||
.attr("class", "title")
|
||||
.attr("text-anchor", "middle")
|
||||
.attr("text-anchor", "end")
|
||||
.attr("transform", function(e) {
|
||||
return "translate( " + width + ",15 )";
|
||||
})
|
||||
.text(title);
|
||||
|
||||
if (time == "hours") {
|
||||
var x = d3.time.scale.utc()
|
||||
.domain([get_utc_time(), date_by_subtracting_days(get_utc_time(), 1)])
|
||||
.rangeRound([0, width]);
|
||||
|
||||
var xAxis = d3.svg.axis()
|
||||
.scale(x)
|
||||
.tickPadding(0)
|
||||
.tickFormat(d3.time.format('%b %d %H'))
|
||||
.ticks(d3.time.hours, 1)
|
||||
.orient("bottom")
|
||||
.tickSize(0)
|
||||
.outerTickSize(0);
|
||||
} else if (time == "days") {
|
||||
var x = d3.time.scale.utc()
|
||||
.domain([get_utc_time(), date_by_subtracting_days(get_utc_time(), 28)])
|
||||
.rangeRound([0, width])
|
||||
.nice();
|
||||
|
||||
var xAxis = d3.svg.axis()
|
||||
.scale(x)
|
||||
.tickPadding(0)
|
||||
.tickFormat(d3.time.format('%b %d'))
|
||||
.ticks(d3.time.days, 1)
|
||||
.orient("bottom")
|
||||
.tickSize(0)
|
||||
.outerTickSize(0);
|
||||
}
|
||||
|
||||
chart.append("g")
|
||||
.attr("class", "x axis")
|
||||
.attr("id", ("x_" + name))
|
||||
.attr("transform", "translate(" + margin.left + "," + (+height + +margin.top )+ ")")
|
||||
.attr("transform", "translate( " + (+margin.left) + "," + (+height + +margin.top )+ ")")
|
||||
.call(xAxis)
|
||||
.selectAll("text")
|
||||
.style("text-anchor", "end")
|
||||
.attr("transform", function() {
|
||||
if(time == "hours") {
|
||||
return "translate( -7, 17)rotate(-90)";
|
||||
} else if(time == "days") {
|
||||
return "translate( -14, 13)rotate(-90)";
|
||||
}
|
||||
return "rotate(-60, 0, " + d3.select(this).node().getBBox().height + ")";
|
||||
});
|
||||
|
||||
chart.append("g")
|
||||
@@ -193,11 +201,21 @@ function create_chart( inp_data, name, time, title ) {
|
||||
return info;
|
||||
});
|
||||
|
||||
var y = d3.scale.linear()
|
||||
.range([height, 0]);
|
||||
|
||||
var yAxis = d3.svg.axis()
|
||||
.scale(y)
|
||||
.orient("left")
|
||||
.tickFormat( function(d) { return d3.round( d*d3.max(data), 0 ) });
|
||||
|
||||
chart.append("g")
|
||||
.attr("class", "y axis")
|
||||
.attr("id", ("y_" + name))
|
||||
.attr("text-anchor", "end")
|
||||
.attr("transform", "translate( " + margin.left + "," + margin.top + ")")
|
||||
.call(yAxis);
|
||||
.call(yAxis)
|
||||
.select(".domain");
|
||||
|
||||
chart.append("g")
|
||||
.append("text")
|
||||
@@ -285,8 +303,7 @@ function create_histogram( inp_data, name, time, title ) {
|
||||
|
||||
// Generate a histogram using twenty uniformly-spaced bins.
|
||||
var data = d3.layout.histogram()
|
||||
.bins(x.ticks(20))
|
||||
(data);
|
||||
.bins(x.ticks(20))(data);
|
||||
|
||||
for(var i = 0; i < data.length; i ++) {
|
||||
lengths.push(data[i].length)
|
||||
|
||||
@@ -1724,6 +1724,7 @@ div.toolTitleNoSection
|
||||
}
|
||||
|
||||
.chart rect {
|
||||
shape-rendering: crispEdges;
|
||||
fill: steelblue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from datetime import datetime, timedelta
|
||||
from galaxy.web.base.controller import BaseUIController, web
|
||||
from galaxy import model
|
||||
import calendar
|
||||
import pkg_resources
|
||||
pkg_resources.require( "SQLAlchemy >= 0.4" )
|
||||
import sqlalchemy as sa
|
||||
@@ -17,7 +18,6 @@ class HomePage( BaseUIController, ReportQueryBuilder ):
|
||||
end_date = datetime.utcnow()
|
||||
end_date = datetime(end_date.year, end_date.month, end_date.day, end_date.hour)
|
||||
start_hours = end_date - timedelta(1)
|
||||
start_days_eta = end_date - timedelta(3)
|
||||
start_days = end_date - timedelta(30)
|
||||
|
||||
jf_hr_data = [0] * 24
|
||||
@@ -41,38 +41,79 @@ class HomePage( BaseUIController, ReportQueryBuilder ):
|
||||
if(job.create_time >= start_hours and
|
||||
job.create_time < end_date ):
|
||||
# Get the creation time for the jobs in the past day
|
||||
time = end_date - job.create_time
|
||||
hours = time.total_seconds() // 3600
|
||||
jc_hr_data[int(hours)] += 1
|
||||
end_day = end_date.day
|
||||
start_day = job.create_time.day
|
||||
end_hour = end_date.hour
|
||||
start_hour = job.create_time.hour
|
||||
|
||||
if(end_day != start_day):
|
||||
hours = (end_hour + 24) - start_hour
|
||||
else:
|
||||
hours = end_hour - start_hour
|
||||
|
||||
if(hours < 24):
|
||||
jc_hr_data[int(hours)] += 1
|
||||
else:
|
||||
jc_dy_data[23] += 1
|
||||
# Get the creation time for jobs in the past 30 days
|
||||
day = (end_date - job.create_time).days
|
||||
jc_dy_data[int(day)] += 1
|
||||
end_month = end_date.month
|
||||
start_month = job.create_time.month
|
||||
end_day = end_date.day
|
||||
start_day = job.create_time.day
|
||||
|
||||
if(end_month != start_month):
|
||||
month_weekday, month_range = calendar.monthrange(job.create_time.year, job.create_time.month)
|
||||
day = (end_day + month_range) - start_day
|
||||
else:
|
||||
day = end_day - start_day
|
||||
|
||||
if(day < 30):
|
||||
jc_dy_data[int(day)] += 1
|
||||
|
||||
if(job.update_time >= start_days and
|
||||
job.update_time < end_date ):
|
||||
if(job.update_time >= start_hours and
|
||||
job.update_time < end_date ):
|
||||
# Get the time finishedfor the jobs in the past day
|
||||
hour = (end_date - job.update_time).total_seconds() // 3600
|
||||
jf_hr_data[int(hour)] += 1
|
||||
end_day = end_date.day
|
||||
start_day = job.update_time.day
|
||||
end_hour = end_date.hour
|
||||
start_hour = job.update_time.hour
|
||||
|
||||
if(end_day != start_day):
|
||||
hours = (end_hour + 24) - start_hour
|
||||
else:
|
||||
hours = end_hour - start_hour
|
||||
|
||||
if(hours < 24):
|
||||
jf_hr_data[int(hours)] += 1
|
||||
|
||||
# Get the Elapsed Time for said job
|
||||
time = (job.update_time - job.create_time)
|
||||
seconds = time.seconds
|
||||
minutes = seconds // 60
|
||||
et_hr_data.append(minutes)
|
||||
# Get the time the job finished and run time in the 30 days
|
||||
end_month = end_date.month
|
||||
start_month = job.update_time.month
|
||||
end_day = end_date.day
|
||||
start_day = job.update_time.day
|
||||
|
||||
if(end_month != start_month):
|
||||
month_weekday, month_range = calendar.monthrange(job.update_time.year, job.update_time.month)
|
||||
day = (end_day + month_range) - start_day
|
||||
else:
|
||||
day = end_day - start_day
|
||||
|
||||
if(day < 30):
|
||||
jf_dy_data[int(day)] += 1
|
||||
|
||||
# Get the Elapsed Time for said job
|
||||
time = (job.update_time - job.create_time)
|
||||
seconds = time.seconds
|
||||
minutes = seconds // 60
|
||||
et_hr_data.append(minutes)
|
||||
# Get the elapsed time for the jobs in the past 3 days
|
||||
if(job.update_time >= start_days_eta and
|
||||
job.update_time < end_date ):
|
||||
time = (job.update_time - job.create_time)
|
||||
seconds = time.seconds
|
||||
minutes = seconds // 60
|
||||
et_dy_data.append(minutes)
|
||||
|
||||
# Get the time the job finished in the 30 days
|
||||
day = (end_date - job.update_time).days
|
||||
jf_dy_data[int(day)] += 1
|
||||
|
||||
return trans.fill_template( '/webapps/reports/run_stats.mako',
|
||||
jf_hr_data=jf_hr_data,
|
||||
jf_dy_data=jf_dy_data,
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+4
-2391
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user