Skip to content

Commit

Permalink
Add an option to keep the ordering of graphs in the order they
Browse files Browse the repository at this point in the history
were added. Default to the old sorted behaviour.
  • Loading branch information
torkelsson committed Nov 13, 2015
1 parent 33dbc8a commit 44a7dbe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
11 changes: 9 additions & 2 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,10 @@ function get_view_graph_elements($view) {
} else {
$graph_args_array[] = "z=" . $default_size;
}

if ( isset($item['sortit']) ) {
$graph_args_array[] = "sortit=" . $item['sortit'];
}

// If graph type is not specified default to line graph
if (isset($item['graph_type']) &&
Expand Down Expand Up @@ -1111,7 +1115,8 @@ function build_aggregate_graph_config ($graph_type,
$hreg,
$mreg,
$glegend,
$exclude_host_from_legend_label) {
$exclude_host_from_legend_label,
$sortit = true) {

global $conf, $index_array, $hosts, $grid, $clusters, $debug, $metrics;

Expand Down Expand Up @@ -1157,7 +1162,9 @@ function build_aggregate_graph_config ($graph_type,
}
}
}
ksort($metric_matches);
if($sortit) {
ksort($metric_matches);
}
}
if( isset($metric_matches)){
$metric_matches_unique = array_unique($metric_matches);
Expand Down
9 changes: 8 additions & 1 deletion graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,20 @@ function build_aggregate_graph_config_from_url($conf_graph_colors) {
$exclude_host_from_legend_label =
(array_key_exists('lgnd_xh', $_GET) &&
$_GET['lgnd_xh'] == "true") ? TRUE : FALSE;

$sortit = true;
if($_GET['sortit'] == "false") {
$sortit = false;
}

$graph_config =
build_aggregate_graph_config($graph_type,
$line_width,
$_GET['hreg'],
$_GET['mreg'],
$graph_legend,
$exclude_host_from_legend_label);
$exclude_host_from_legend_label,
$sortit);
}

// Set up
Expand Down

0 comments on commit 44a7dbe

Please sign in to comment.