Skip to content

Instantly share code, notes, and snippets.

@cbushell
Created November 22, 2010 09:06
Show Gist options
  • Save cbushell/709705 to your computer and use it in GitHub Desktop.
Save cbushell/709705 to your computer and use it in GitHub Desktop.
Plotting build times with jQuery, Flot and DateJS
$(document).ready(
function() {
var builds = [
{ url: "/build_results/start",
legend: "Start"
}
];
$.each(builds, function(build_index, build) {
$.get(build.url, function(data) {
var rows = data.split(/\n/);
var data_series = [];
$.each(rows, function(row_index, row) {
if (row_index > 0) {
var tokens = row.split(",");
var build_duration = tokens[1];
var build_start_time = Date.parse(tokens[8]);
var build_status = tokens[3];
if (build_status == 'Passed') {
data_series.push([build_start_time.getTime(), build_duration]);
}
}
});
all_builds_series.push({label: build.legend, data: data_series});
});
});
}).ajaxStop(function() {
$.plot($("#all_builds"), all_builds_series, {
xaxis: { mode: "time" },
yaxis: { tickFormatter:
function(milliseconds) {
return new TimeSpan(milliseconds * 1000).toString("mm:ss");
}},
legend: { show: true,
noColumns: all_builds_series.length }
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment