Better labels for metrics-on-canvas, log scale for load and open-files

- Small fixes after the rebase
This commit is contained in:
Simon Howe
2016-04-04 17:48:42 +02:00
parent 0f21c1b5e7
commit f8a69fa1fa
3 changed files with 35 additions and 5 deletions
+13 -1
View File
@@ -1,6 +1,7 @@
import _ from 'lodash';
import d3 from 'd3';
import { formatMetric } from './string-utils';
import AppStore from '../stores/app-store';
// Inspired by Lee Byron's test data generator.
@@ -78,6 +79,10 @@ export function addMetrics(delta, prevNodes) {
});
}
const openFilesScale = d3.scale.log().domain([1, 100000]).range([0, 1]);
//
// loadScale(1) == 0.5; E.g. a nicely balanced system :).
const loadScale = d3.scale.log().domain([0.01, 100]).range([0, 1]);
export function getMetricValue(metric, size) {
if (!metric) {
@@ -86,7 +91,14 @@ export function getMetricValue(metric, size) {
const max = metric.getIn(['max']);
const value = metric.getIn(['samples', 0, 'value']);
const valuePercentage = value === 0 ? 0 : value / max;
let valuePercentage = value === 0 ? 0 : value / max;
if (AppStore.getSelectedMetric() === 'open_files_count') {
valuePercentage = openFilesScale(value);
} else if (_.includes(['load1', 'load5', 'load15'], AppStore.getSelectedMetric())) {
valuePercentage = loadScale(value);
}
const baseline = 0.05;
const displayedValue = valuePercentage * (1 - baseline) + baseline;
const height = size * displayedValue;