diff --git a/packages/xo-web/src/common/xo-line-chart/index.js b/packages/xo-web/src/common/xo-line-chart/index.js index 1b406ba73..086c632f1 100644 --- a/packages/xo-web/src/common/xo-line-chart/index.js +++ b/packages/xo-web/src/common/xo-line-chart/index.js @@ -1,10 +1,22 @@ import ChartistGraph from 'react-chartist' import ChartistLegend from 'chartist-plugin-legend' import ChartistTooltip from 'chartist-plugin-tooltip' +import humanFormat from 'human-format' import React from 'react' import { injectIntl } from 'react-intl' import { messages } from 'intl' -import { find, flatten, floor, get, map, max, size, sum, values } from 'lodash' +import { + find, + flatten, + floor, + get, + map, + max, + round, + size, + sum, + values, +} from 'lodash' import propTypes from '../prop-types-decorator' import { computeArraysSum } from '../xo-stats' @@ -87,9 +99,9 @@ const makeLabelInterpolationFnc = (intl, nValues, endTimestamp, interval) => { return (value, index) => index % labelSpace === 0 ? intl.formatTime( - (endTimestamp - (nValues - index - 1) * interval) * 1000, - format - ) + (endTimestamp - (nValues - index - 1) * interval) * 1000, + format + ) : null } @@ -441,19 +453,19 @@ export const PoolPifLineChart = injectIntl( const series = addSumSeries ? map(ios, io => ({ - name: `${intl.formatMessage(messages.poolAllHosts)} (${io})`, - data: computeArraysSum( - map(data, ({ stats }) => computeArraysSum(stats.pifs[io])) - ), - })) + name: `${intl.formatMessage(messages.poolAllHosts)} (${io})`, + data: computeArraysSum( + map(data, ({ stats }) => computeArraysSum(stats.pifs[io])) + ), + })) : flatten( - map(data, ({ stats, host }) => - map(ios, io => ({ - name: `${host} (${io})`, - data: computeArraysSum(stats.pifs[io]), - })) + map(data, ({ stats, host }) => + map(ios, io => ({ + name: `${host} (${io})`, + data: computeArraysSum(stats.pifs[io]), + })) + ) ) - ) return ( `${value.toPrecision(3)} /s`, + valueTransform: value => + humanFormat(value, { + decimals: 3, + unit: 'IOPS', + }), }), ...options, }} @@ -721,7 +737,7 @@ export const IowaitChart = injectIntl( nValues: length, endTimestamp, interval, - valueTransform: value => `${value.toPrecision(2)}%`, + valueTransform: value => `${round(value, 2)}%`, }), ...options, }}