Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

allow sort by max value

  • Loading branch information...
commit 8303b86134a73ae5f2c925a2de034806545e18db 1 parent ee4a1b0
Jordan Evans authored
Showing with 39 additions and 13 deletions.
  1. +38 −13 railroad/static/js/functions.js
  2. +1 −0  railroad/templates/toolbar.html
View
51 railroad/static/js/functions.js
@@ -288,9 +288,18 @@ var sorts = {
})),
'duration': makeComparer(function(so) {
return so['duration'];
+ }),
+ 'max': makeComparer(function(so) {
+ if (so['data'] && so['data']['options'] && so['data']['options']['yaxis'] && so['data']['options']['yaxis']['max']){
+ return so['data']['options']['yaxis']['max'];
+ } else {
+ return 0;
+ }
})
}
+sorts['max'].usesData = true;
+
/* Do the sorting. */
function sortGraphs(name, reversed) {
var sorter = sorts[name];
@@ -300,6 +309,11 @@ function sortGraphs(name, reversed) {
var finishSort = function() {
var meta = $('#graphs').data('meta');
+ for (var i=0; i < meta.length; i++) {
+ if (meta[i].data.data) {
+ meta[i].data = addMaxToData(meta[i].data);
+ }
+ }
meta.sort(sorter);
$('graphs').data('meta', meta);
selectServiceObjs();
@@ -1069,26 +1083,37 @@ function getServiceObjs(ajaxData) {
});
}
+function addMaxToData(data) {
+ var max = null;
+ if (data.data) {
+ for (var i=0; i < data.data.length; i++) {
+ if (data.data[i].lines.show) {
+ for (var j=0; j < data.data[i].data.length; j++) {
+ var val = data.data[i].data[j][1];
+ if (( val > max && val != null) || first ) {
+ max = val;
+ first = false;
+ }
+ }
+ }
+ }
+ }
+ if (data.options && data.options.yaxis && max) {
+ data.options.yaxis.max = max * 1.2;
+ }
+ return data;
+}
+
+
// Takes the raw data and sets up required Flot formatting options
function formatGraph(element, data) {
base = data.base;
var first = true;
var max = null;
- for (var i=0; i < data.data.length; i++) {
- if (data.data[i].lines.show) {
- for (var j=0; j < data.data[i].data.length; j++) {
- var val = data.data[i].data[j][1];
- if (( val > max && val != null) || first ) {
- max = val;
- first = false;
- }
- }
- }
- }
+ data = addMaxToData(data);
- data.options.yaxis.max = max * 1.2;
- if ( max ) {
+ if ( data.options.yaxis.max ) {
data.options.yaxis.show = true;
data.options.yaxis.ticks = tickGenerator;
data.options.yaxis.tickFormatter = tickFormatter;
View
1  railroad/templates/toolbar.html
@@ -57,5 +57,6 @@
<li name="host">Host Name</li>
<li name="status">Status</li>
<li name="duration">Duration</li>
+ <li name="max">Max Value</li>
</ul>
</div>
Please sign in to comment.
Something went wrong with that request. Please try again.