+ {_.map(METRICS, (key, name) => {
+ return (
+
onMouseOver(key)}>
+ {name}
+
+ );
+ })}
+
+ );
+}
diff --git a/client/app/scripts/constants/action-types.js b/client/app/scripts/constants/action-types.js
index 047dc8274..87aac25b9 100644
--- a/client/app/scripts/constants/action-types.js
+++ b/client/app/scripts/constants/action-types.js
@@ -33,7 +33,8 @@ const ACTION_TYPES = [
'RECEIVE_TOPOLOGIES',
'RECEIVE_API_DETAILS',
'RECEIVE_ERROR',
- 'ROUTE_TOPOLOGY'
+ 'ROUTE_TOPOLOGY',
+ 'SELECT_METRIC'
];
export default _.zipObject(ACTION_TYPES, ACTION_TYPES);
diff --git a/client/app/scripts/stores/app-store.js b/client/app/scripts/stores/app-store.js
index ebfef2e41..8e3115666 100644
--- a/client/app/scripts/stores/app-store.js
+++ b/client/app/scripts/stores/app-store.js
@@ -58,6 +58,7 @@ let routeSet = false;
let controlPipes = makeOrderedMap(); // pipeId -> controlPipe
let updatePausedAt = null; // Date
let websocketClosed = true;
+let selectedMetric = 'process_cpu_usage_percent';
const topologySorter = topology => topology.get('rank');
@@ -164,6 +165,10 @@ export class AppStore extends Store {
return adjacentNodes;
}
+ getSelectedMetric() {
+ return selectedMetric;
+ }
+
getControlStatus() {
return controlStatus.toJS();
}
@@ -401,6 +406,11 @@ export class AppStore extends Store {
}
break;
}
+ case ActionTypes.SELECT_METRIC: {
+ selectedMetric = payload.metricId;
+ this.__emitChange();
+ break;
+ }
case ActionTypes.DESELECT_NODE: {
closeNodeDetails();
this.__emitChange();
diff --git a/client/app/scripts/utils/data-utils.js b/client/app/scripts/utils/data-utils.js
index 600abaffc..d7276ce51 100644
--- a/client/app/scripts/utils/data-utils.js
+++ b/client/app/scripts/utils/data-utils.js
@@ -78,19 +78,19 @@ export function addMetrics(delta, prevNodes) {
}
-export function getMetricValue(metrics, size) {
- if (!metrics) {
- return {height: 0, vp: null};
+export function getMetricValue(metric, size) {
+ if (!metric) {
+ return {height: 0, v: null};
}
- const max = 100;
- const v = metrics.getIn(['process_cpu_usage_percent', 'samples', 0, 'value']);
+ const max = metric.getIn(['max']);
+ const v = metric.getIn(['samples', 0, 'value']);
const vp = v === 0 ? 0 : v / max;
- const baseline = 0.00;
+ const baseline = 0.05;
const displayedValue = vp * (1 - baseline) + baseline;
const height = size * displayedValue;
- return {height, vp};
+ return {height, v};
}
const formatLargeValue = d3.format('s');
@@ -98,5 +98,5 @@ export function formatCanvasMetric(v) {
if (v === null) {
return 'n/a';
}
- return formatLargeValue(Number(v * 100).toFixed(1)) + '%';
+ return formatLargeValue(Number(v).toFixed(1));
}