Skip to content

Commit

Permalink
Merge pull request #272 from torkelsson/gweb-sort
Browse files Browse the repository at this point in the history
Add an option to keep the ordering of graphs in the order they appear #228
  • Loading branch information
vvuksan committed Nov 16, 2015
2 parents 33dbc8a + ee205e1 commit 280fc04
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 280fc04

Please sign in to comment.