Private GIT

Skip to content
Snippets Groups Projects
Commit b08b225b authored by Maximilien Bersoult's avatar Maximilien Bersoult
Browse files

Add stack options on chart

parent f7f71725
Branches
Tags
No related merge requests found
......@@ -65,7 +65,9 @@ class CentreonMetric extends CentreonWebService {
} else {
$q = $this->arguments['q'];
}
$query = "SELECT DISTINCT(`metric_name`) COLLATE utf8_bin as \"metric_name\" FROM `metrics` WHERE metric_name LIKE '%$q%' ORDER BY `metric_name` COLLATE utf8_general_ci ";
$query = "SELECT DISTINCT(`metric_name`) COLLATE utf8_bin as \"metric_name\"
FROM `metrics`
WHERE metric_name LIKE '%$q%' ORDER BY `metric_name` COLLATE utf8_general_ci ";
$DBRESULT = $this->pearDBMonitoring->query($query);
$metrics = array();
while ($row = $DBRESULT->fetchRow()) {
......
......@@ -100,7 +100,8 @@ class CentreonGraphService extends CentreonGraph
"graph_type" => "line",
"unit" => $metric["unit"],
"color" => $metric["ds_color_line"],
"negative" => false
"negative" => false,
"stack" => false
);
if (isset($metric['ds_color_area'])) {
$info['graph_type'] = "area";
......@@ -108,6 +109,9 @@ class CentreonGraphService extends CentreonGraph
if (isset($metric['ds_invert']) && $metric['ds_invert'] == 1) {
$info['negative'] = true;
}
if (isset($metric['stack'])) {
$info['stack'] = $metric['stack'] == 1 ? true : false;
}
$metrics[] = $info;
}
$i++;
......
......@@ -265,6 +265,10 @@
}
data.x = 'times';
/* Add group */
data.groups = this.buildGroups(dataRaw);
return {
data: data,
axis: axis
......@@ -322,6 +326,26 @@
return regions;
},
/**
* Build regions
*
* @param {Object} data - The chart datas
* @return {Array} - The list of regions
*/
buildGroups: function (data) {
var group = [];
var i;
var name;
for (i = 0; i < data.data.length; i++) {
name = 'data' + (i + 1);
if (data.data[i].stack) {
group.push(name);
}
}
return [group];
},
/**
* Refresh data of graph
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment